Skip to content

Commit

Permalink
Axolotl+Goats - Bump to dev5
Browse files Browse the repository at this point in the history
New:
- Added Goats
- Added Axolotls

Bump to dev5
  • Loading branch information
Jakllp committed Aug 24, 2021
1 parent 1dd9bd1 commit 5fd1478
Show file tree
Hide file tree
Showing 14 changed files with 442 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ public static class Ghast {
public static boolean CAN_GLIDE = true;
}

public static class Goat {
public static boolean CAN_GIVE_MILK = true;
public static ConfigItem GROW_UP_ITEM;

}

public static class Hoglin {

public static ConfigItem GROW_UP_ITEM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import java.util.List;

public enum MyPetType {
Axolotl("AXOLOTL", "1.17.1", MyAxolotl.class, new Compat<>()
.v("1.17.1", "axolotl")
.search()),
Bat("BAT", "1.7.10", MyBat.class, new Compat<>()
.v("1.7.10", 65)
.v("1.13", "bat")
Expand Down Expand Up @@ -99,6 +102,9 @@ public enum MyPetType {
.v("1.7.10", 56)
.v("1.13", "ghast")
.search()),
Goat("GOAT", "1.17.1", MyGoat.class, new Compat<>()
.v("1.17.1", "goat")
.search()),
Giant("GIANT", "1.7.10", MyGiant.class, new Compat<>()
.v("1.7.10", 53)
.v("1.13", "giant")
Expand Down
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);
}
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 {

}
2 changes: 1 addition & 1 deletion modules/MyPet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>de.keyle</groupId>
<artifactId>mypet</artifactId>
<version>3.12-dev4</version>
<version>3.12-dev5</version>
<packaging>jar</packaging>
<name>MyPet</name>
<url>https://www.spigotmc.org/resources/mypet.12725/</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public class CommandOptionCreate implements CommandOptionTabCompleter {
commonTypeOptionList.add("skilltree:");
commonTypeOptionList.add("name:");

petTypeOptionMap.put("axolotl", new CommandOptionCreator()
.add("baby")
.add("type:")
.get());

petTypeOptionMap.put("bee", new CommandOptionCreator()
.add("baby")
.add("angry")
Expand Down Expand Up @@ -110,6 +115,10 @@ public class CommandOptionCreate implements CommandOptionTabCompleter {
.add("type:white")
.get());

petTypeOptionMap.put("goat", new CommandOptionCreator()
.add("baby")
.get());

petTypeOptionMap.put("guardian", new CommandOptionCreator()
.add("1.7.10", "1.11", "elder")
.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.lang.reflect.Constructor;

public enum MyPetClass {
Axolotl(MyAxolotl.class),
Bat(MyBat.class),
Bee(MyBee.class),
Blaze(MyBlaze.class),
Expand All @@ -47,6 +48,7 @@ public enum MyPetClass {
Evoker(MyEvoker.class),
Fox(MyFox.class),
Ghast(MyGhast.class),
Goat(MyGoat.class),
Giant(MyGiant.class),
Guardian(MyGuardian.class),
Hoglin(MyHoglin.class),
Expand Down
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() + "}";
}
}
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() + "}";
}
}
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;
}
}
Loading

0 comments on commit 5fd1478

Please sign in to comment.