Skip to content

Commit

Permalink
Add super fertilizers for creeperlings, closes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Apr 12, 2023
1 parent d184672 commit 4c7dddd
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'io.github.ladysnake.chenille' version '0.10.1'
id 'io.github.ladysnake.chenille' version '0.10.2'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
------------------------------------------------------
Version 1.12.0
------------------------------------------------------
- Added a `creeperspores:super_fertilizers` tag for items that make plants (and thus creeperlings) grow instantly
- The specific tag for creeperling fertilizers is now `creeperspores:fertilizers`
- Adding entries to `c:fertilizers` will still work like before

------------------------------------------------------
Version 1.11.0
------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ quilted_fabric_api_version = 6.0.0-beta.2+0.76.0

# Base properties
mod_name = Creeper Spores
mod_version = 1.11.0
mod_version = 1.12.0
owners = Ladysnake
maven_group = io.github.ladysnake

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public class CreeperSpores implements ModInitializer {
new Identifier("mobz", "crip_entity")
));

public static final TagKey<Item> FERTILIZERS = TagKey.of(RegistryKeys.ITEM, new Identifier("c", "fertilizers"));
public static final TagKey<Item> FERTILIZERS = TagKey.of(RegistryKeys.ITEM, id("fertilizers"));
public static final TagKey<Item> SUPER_FERTILIZERS = TagKey.of(RegistryKeys.ITEM, id("super_fertilizers"));
public static final TagKey<DamageType> SPAWNS_MORE_CREEPERLINGS = TagKey.of(RegistryKeys.DAMAGE_TYPE, id("spawns_more_creeperlings"));
public static final TagKey<DamageType> EXTRA_CREEPER_DAMAGE = TagKey.of(RegistryKeys.DAMAGE_TYPE, id("extra_creeper_damage"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ public static boolean interactSpawnEgg(PlayerEntity player, Entity interacted, I

public void applyFertilizer(ItemStack boneMeal) {
if (!this.world.isClient && this.ticksInSunlight < MATURATION_TIME) {
this.ticksInSunlight += (20 * (60 + 120 * this.random.nextFloat()));
if (boneMeal.isIn(CreeperSpores.SUPER_FERTILIZERS)) {
this.ticksInSunlight = MATURATION_TIME;
} else {
this.ticksInSunlight += (20 * (60 + 120 * this.random.nextFloat()));
}

boneMeal.decrement(1);
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeInt(this.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"#c:fertilizers",
"#creeperspores:super_fertilizers"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"replace": false,
"values": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,30 @@ public void creeperlingsGrowWithBonemeal(TestContext ctx) {
creeperling.setCustomName(Text.of("Bobby"));
PlayerEntity player = ctx.createMockPlayer();
player.setStackInHand(Hand.MAIN_HAND, new ItemStack(Items.BONE_MEAL, 64));
for (int i = 0; i < 8; i++) {
creeperling.interact(player, Hand.MAIN_HAND);
}
creeperling.interact(player, Hand.MAIN_HAND);

ctx.waitAndRun(1, () -> {
// A single bone meal should not cause the creeper to grow up
ctx.expectEntityWithData(new BlockPos(1, 0, 1), CreeperEntry.getVanilla().creeperlingType(), Entity::getCustomName, Text.of("Bobby"));
for (int i = 0; i < 7; i++) {
creeperling.interact(player, Hand.MAIN_HAND);
}

ctx.waitAndRun(1, () -> {
ctx.expectNoEntity(CreeperEntry.getVanilla().creeperlingType());
ctx.expectEntityWithData(new BlockPos(1, 0, 1), EntityType.CREEPER, Entity::getCustomName, Text.of("Bobby"));
ctx.complete();
});
});
}

@GameTest(structureName = EMPTY_STRUCTURE)
public void creeperlingsGrowInstantlyWithSuperFertilizer(TestContext ctx) {
CreeperlingEntity creeperling = ctx.spawnMob(CreeperEntry.getVanilla().creeperlingType(), 1, 0, 1);
creeperling.setCustomName(Text.of("Bobby"));
PlayerEntity player = ctx.createMockPlayer();
player.setStackInHand(Hand.MAIN_HAND, new ItemStack(Items.PORKCHOP, 1));
creeperling.interact(player, Hand.MAIN_HAND);
ctx.waitAndRun(1, () -> {
ctx.expectNoEntity(CreeperEntry.getVanilla().creeperlingType());
ctx.expectEntityWithData(new BlockPos(1, 0, 1), EntityType.CREEPER, Entity::getCustomName, Text.of("Bobby"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:porkchop"
]
}

0 comments on commit 4c7dddd

Please sign in to comment.