forked from mofucraft/MyPet
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: - Added Goats - Added Axolotls Bump to dev5
- Loading branch information
Showing
14 changed files
with
442 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyAxolotl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* This file is part of MyPet | ||
* | ||
* Copyright © 2011-2019 Keyle | ||
* MyPet is licensed under the GNU Lesser General Public License. | ||
* | ||
* MyPet is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MyPet is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.Keyle.MyPet.api.entity.types; | ||
|
||
import de.Keyle.MyPet.api.entity.DefaultInfo; | ||
import de.Keyle.MyPet.api.entity.MyPet; | ||
import de.Keyle.MyPet.api.entity.MyPetBaby; | ||
@DefaultInfo(food = {"bucket"}) | ||
public interface MyAxolotl extends MyPet, MyPetBaby { | ||
|
||
int getVariant(); | ||
|
||
void setVariant(int variant); | ||
} |
31 changes: 31 additions & 0 deletions
31
modules/API/src/main/java/de/Keyle/MyPet/api/entity/types/MyGoat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* This file is part of MyPet | ||
* | ||
* Copyright © 2011-2019 Keyle | ||
* MyPet is licensed under the GNU Lesser General Public License. | ||
* | ||
* MyPet is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MyPet is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.Keyle.MyPet.api.entity.types; | ||
|
||
import de.Keyle.MyPet.api.entity.DefaultInfo; | ||
import de.Keyle.MyPet.api.entity.MyPet; | ||
import de.Keyle.MyPet.api.entity.MyPetBaby; | ||
|
||
|
||
@DefaultInfo(food = {"wheat"}) | ||
public interface MyGoat extends MyPet, MyPetBaby { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyAxolotl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* This file is part of MyPet | ||
* | ||
* Copyright © 2011-2019 Keyle | ||
* MyPet is licensed under the GNU Lesser General Public License. | ||
* | ||
* MyPet is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MyPet is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.Keyle.MyPet.entity.types; | ||
|
||
import de.Keyle.MyPet.api.entity.MyPetType; | ||
import de.Keyle.MyPet.api.player.MyPetPlayer; | ||
import de.Keyle.MyPet.entity.MyPet; | ||
import de.keyle.knbt.TagByte; | ||
import de.keyle.knbt.TagCompound; | ||
import de.keyle.knbt.TagInt; | ||
import org.bukkit.ChatColor; | ||
|
||
public class MyAxolotl extends MyPet implements de.Keyle.MyPet.api.entity.types.MyAxolotl { | ||
|
||
protected boolean isBaby = false; | ||
protected int axolotlType = 1; | ||
|
||
public MyAxolotl(MyPetPlayer petOwner) { | ||
super(petOwner); | ||
} | ||
@Override | ||
public TagCompound writeExtendedInfo() { | ||
TagCompound info = super.writeExtendedInfo(); | ||
info.getCompoundData().put("Baby", new TagByte(isBaby())); | ||
info.getCompoundData().put("Variant", new TagInt(getVariant())); | ||
return info; | ||
} | ||
|
||
@Override | ||
public void readExtendedInfo(TagCompound info) { | ||
if (info.containsKey("Variant")) { | ||
setVariant(info.getAs("Variant", TagInt.class).getIntData()); | ||
} | ||
if (info.containsKey("Baby")) { | ||
setBaby(info.getAs("Baby", TagByte.class).getBooleanData()); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public MyPetType getPetType() { | ||
return MyPetType.Axolotl; | ||
} | ||
|
||
@Override | ||
public int getVariant() { | ||
return axolotlType; | ||
} | ||
|
||
@Override | ||
public void setVariant(int variant) { | ||
this.axolotlType = Math.min(4, Math.max(0, variant)); | ||
if (status == PetState.Here) { | ||
getEntity().ifPresent(entity -> entity.getHandle().updateVisuals()); | ||
} | ||
} | ||
|
||
public boolean isBaby() { | ||
return isBaby; | ||
} | ||
|
||
public void setBaby(boolean flag) { | ||
this.isBaby = flag; | ||
if (status == PetState.Here) { | ||
getEntity().ifPresent(entity -> entity.getHandle().updateVisuals()); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MyAxolotl{owner=" + getOwner().getName() + ", name=" + ChatColor.stripColor(petName) + ", exp=" + experience.getExp() + "/" + experience.getRequiredExp() + ", lv=" + experience.getLevel() + ", status=" + status.name() + ", skilltree=" + (skilltree != null ? skilltree.getName() : "-") + ", worldgroup=" + worldGroup + ", baby=" + isBaby() + "}"; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
modules/Plugin/src/main/java/de/Keyle/MyPet/entity/types/MyGoat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This file is part of MyPet | ||
* | ||
* Copyright © 2011-2019 Keyle | ||
* MyPet is licensed under the GNU Lesser General Public License. | ||
* | ||
* MyPet is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MyPet is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.Keyle.MyPet.entity.types; | ||
|
||
import de.Keyle.MyPet.api.entity.MyPetType; | ||
import de.Keyle.MyPet.api.player.MyPetPlayer; | ||
import de.Keyle.MyPet.entity.MyPet; | ||
import de.keyle.knbt.TagByte; | ||
import de.keyle.knbt.TagCompound; | ||
import org.bukkit.ChatColor; | ||
|
||
public class MyGoat extends MyPet implements de.Keyle.MyPet.api.entity.types.MyGoat { | ||
protected boolean isBaby = false; | ||
|
||
public MyGoat(MyPetPlayer petOwner) { | ||
super(petOwner); | ||
} | ||
|
||
@Override | ||
public TagCompound writeExtendedInfo() { | ||
TagCompound info = super.writeExtendedInfo(); | ||
info.getCompoundData().put("Baby", new TagByte(isBaby())); | ||
return info; | ||
} | ||
|
||
@Override | ||
public void readExtendedInfo(TagCompound info) { | ||
if (info.containsKey("Baby")) { | ||
setBaby(info.getAs("Baby", TagByte.class).getBooleanData()); | ||
} | ||
} | ||
|
||
@Override | ||
public MyPetType getPetType() { | ||
return MyPetType.Goat; | ||
} | ||
|
||
public boolean isBaby() { | ||
return isBaby; | ||
} | ||
|
||
public void setBaby(boolean flag) { | ||
this.isBaby = flag; | ||
if (status == PetState.Here) { | ||
getEntity().ifPresent(entity -> entity.getHandle().updateVisuals()); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MyGoat{owner=" + getOwner().getName() + ", name=" + ChatColor.stripColor(petName) + ", exp=" + experience.getExp() + "/" + experience.getRequiredExp() + ", lv=" + experience.getLevel() + ", status=" + status.name() + ", skilltree=" + (skilltree != null ? skilltree.getName() : "-") + ", worldgroup=" + worldGroup + ", baby=" + isBaby() + "}"; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...s/v1_17_R1/src/main/java/de/Keyle/MyPet/compat/v1_17_R1/entity/types/EntityMyAxolotl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* This file is part of MyPet | ||
* | ||
* Copyright © 2011-2020 Keyle | ||
* MyPet is licensed under the GNU Lesser General Public License. | ||
* | ||
* MyPet is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MyPet is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.Keyle.MyPet.compat.v1_17_R1.entity.types; | ||
|
||
import de.Keyle.MyPet.api.entity.EntitySize; | ||
import de.Keyle.MyPet.api.entity.MyPet; | ||
import de.Keyle.MyPet.api.entity.types.MyAxolotl; | ||
import de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet; | ||
import net.minecraft.network.syncher.EntityDataAccessor; | ||
import net.minecraft.network.syncher.EntityDataSerializers; | ||
import net.minecraft.network.syncher.SynchedEntityData; | ||
import net.minecraft.world.level.Level; | ||
|
||
@EntitySize(width = 0.7F, height = 1.3F) | ||
public class EntityMyAxolotl extends EntityMyPet { | ||
|
||
private static final EntityDataAccessor<Boolean> AGE_WATCHER = SynchedEntityData.defineId(EntityMyAxolotl.class, EntityDataSerializers.BOOLEAN); | ||
private static final EntityDataAccessor<Integer> VARIANT_WATCHER = SynchedEntityData.defineId(EntityMyAxolotl.class, EntityDataSerializers.INT); | ||
|
||
public EntityMyAxolotl(Level world, MyPet myPet) { | ||
super(world, myPet); | ||
} | ||
|
||
@Override | ||
protected String getMyPetDeathSound() { | ||
return "entity.axolotl.death"; | ||
} | ||
|
||
@Override | ||
protected String getHurtSound() { | ||
return "entity.axolotl.hurt"; | ||
} | ||
|
||
@Override | ||
protected String getLivingSound() { | ||
return "entity.axolotl.idle_air"; | ||
} | ||
|
||
@Override | ||
protected void defineSynchedData() { | ||
super.defineSynchedData(); | ||
getEntityData().define(AGE_WATCHER, false); | ||
getEntityData().define(VARIANT_WATCHER, 0); | ||
} | ||
|
||
@Override | ||
public void updateVisuals() { | ||
this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby()); | ||
this.getEntityData().set(VARIANT_WATCHER, getMyPet().getVariant()); | ||
} | ||
|
||
@Override | ||
public void playPetStepSound() { | ||
makeSound("entity.axolotl.step", 0.15F, 1.0F); | ||
} | ||
|
||
@Override | ||
public MyAxolotl getMyPet() { | ||
return (MyAxolotl) myPet; | ||
} | ||
} |
Oops, something went wrong.