Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
seymourimadeit committed Jul 8, 2024
1 parent a64f08d commit 46b9c55
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ minecraft_version=1.21
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21, 1.22)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.0.52-beta
neo_version=21.0.76-beta
# The Neo version range can use any version of Neo as bounds or match the loader version range
neo_version_range=[20.5.14,)
# The loader version range can only use the major version of Neo/FML as bounds
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tallestred/piglinproliferation/PPEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ public static void attackEntity(LivingIncomingDamageEvent event) {
@SubscribeEvent
public static void targetMob(LivingChangeTargetEvent event) {
if (event.getEntity() instanceof AbstractPiglin) {
if (event.getOriginalTarget() instanceof AbstractPiglin) {
if (event.getOriginalAboutToBeSetTarget() instanceof AbstractPiglin) {
event.setCanceled(true);
}
}
if (event.getEntity() instanceof ZombifiedPiglin) {
if (event.getOriginalTarget() instanceof ZombifiedPiglin) {
if (event.getOriginalAboutToBeSetTarget() instanceof ZombifiedPiglin) {
event.setCanceled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.SpawnPlacementTypes;
import net.minecraft.world.item.*;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
Expand All @@ -31,31 +33,29 @@
import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent;
import net.neoforged.fml.event.lifecycle.InterModProcessEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.common.util.MutableHashedLinkedMap;
import net.neoforged.neoforge.common.util.InsertableLinkedOpenCustomHashSet;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
import net.neoforged.neoforge.event.entity.EntityAttributeCreationEvent;
import net.neoforged.neoforge.event.entity.EntityAttributeModificationEvent;
import net.neoforged.neoforge.event.entity.SpawnPlacementRegisterEvent;
import net.neoforged.neoforge.event.entity.RegisterSpawnPlacementsEvent;
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
import net.neoforged.neoforge.registries.datamaps.DataMapType;
import net.neoforged.neoforge.registries.datamaps.RegisterDataMapTypesEvent;
import net.neoforged.neoforge.registries.datamaps.builtin.Compostable;
import tallestred.piglinproliferation.capablities.PPDataAttachments;
import tallestred.piglinproliferation.client.PPSounds;
import tallestred.piglinproliferation.common.advancement.PPCriteriaTriggers;
import tallestred.piglinproliferation.common.attribute.PPAttributes;
import tallestred.piglinproliferation.common.blockentities.FireRingBlockEntity;
import tallestred.piglinproliferation.common.enchantments.PPEnchantments;
import tallestred.piglinproliferation.common.entities.PiglinTraveler;
import tallestred.piglinproliferation.common.entities.ZombifiedPiglinVariant;
import tallestred.piglinproliferation.common.items.BucklerItem;
import tallestred.piglinproliferation.common.items.PPItems;
import tallestred.piglinproliferation.common.blockentities.PPBlockEntities;
import tallestred.piglinproliferation.common.blocks.PPBlocks;
import tallestred.piglinproliferation.common.entities.PPEntityTypes;
import tallestred.piglinproliferation.common.entities.PiglinAlchemist;
import tallestred.piglinproliferation.common.entities.PiglinTraveler;
import tallestred.piglinproliferation.common.entities.ZombifiedPiglinVariant;
import tallestred.piglinproliferation.common.items.BucklerItem;
import tallestred.piglinproliferation.common.items.PPItems;
import tallestred.piglinproliferation.common.items.component.PPComponents;
import tallestred.piglinproliferation.common.items.component.TravelersCompassTracker;
import tallestred.piglinproliferation.common.loot.PPLoot;
Expand Down Expand Up @@ -123,18 +123,17 @@ private void addDataMaps(RegisterDataMapTypesEvent event) {
}

private void addCreativeTabs(final BuildCreativeModeTabContentsEvent event) {
MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> creativeTab = event.getEntries();
if (CreativeModeTabs.SPAWN_EGGS.equals(event.getTabKey())) {
addToCreativeTabAfter(creativeTab, Items.PIGLIN_SPAWN_EGG, PPItems.PIGLIN_ALCHEMIST_SPAWN_EGG.get());
addToCreativeTabAfter(creativeTab, Items.PIGLIN_BRUTE_SPAWN_EGG, PPItems.PIGLIN_TRAVELER_SPAWN_EGG.get());
addToCreativeTabAfter(event, Items.PIGLIN_SPAWN_EGG, PPItems.PIGLIN_ALCHEMIST_SPAWN_EGG.get());
addToCreativeTabAfter(event, Items.PIGLIN_BRUTE_SPAWN_EGG, PPItems.PIGLIN_TRAVELER_SPAWN_EGG.get());
} else if (CreativeModeTabs.FUNCTIONAL_BLOCKS.equals(event.getTabKey())) {
addToCreativeTabAfter(creativeTab, Items.PIGLIN_HEAD,
addToCreativeTabAfter(event, Items.PIGLIN_HEAD,
PPItems.PIGLIN_ALCHEMIST_HEAD_ITEM.get(),
PPItems.PIGLIN_TRAVELER_HEAD_ITEM.get(),
PPItems.PIGLIN_BRUTE_HEAD_ITEM.get(),
PPItems.ZOMBIFIED_PIGLIN_HEAD_ITEM.get()
);
addToCreativeTabAfter(creativeTab, Items.SOUL_CAMPFIRE,
addToCreativeTabAfter(event, Items.SOUL_CAMPFIRE,
PPItems.STONE_FIRE_RING_ITEM.get(),
PPItems.STONE_SOUL_FIRE_RING_ITEM.get(),
PPItems.DEEPSLATE_FIRE_RING_ITEM.get(),
Expand All @@ -146,13 +145,14 @@ private void addCreativeTabs(final BuildCreativeModeTabContentsEvent event) {
PPItems.END_STONE_FIRE_RING_ITEM.get(),
PPItems.END_STONE_SOUL_FIRE_RING_ITEM.get()
);
} else if (CreativeModeTabs.COMBAT.equals(event.getTabKey()))
addToCreativeTabAfter(creativeTab, Items.SHIELD, PPItems.BUCKLER.get());
} else if (CreativeModeTabs.COMBAT.equals(event.getTabKey())) {
addToCreativeTabAfter(event, Items.SHIELD, PPItems.BUCKLER.get());
}
}

private void addSpawn(final SpawnPlacementRegisterEvent event) {
event.register(PPEntityTypes.PIGLIN_ALCHEMIST.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, PiglinAlchemist::checkChemistSpawnRules, SpawnPlacementRegisterEvent.Operation.AND);
event.register(PPEntityTypes.PIGLIN_TRAVELER.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, PiglinTraveler::checkTravelerSpawnRules, SpawnPlacementRegisterEvent.Operation.AND);
private void addSpawn(final RegisterSpawnPlacementsEvent event) {
event.register(PPEntityTypes.PIGLIN_ALCHEMIST.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, PiglinAlchemist::checkChemistSpawnRules, RegisterSpawnPlacementsEvent.Operation.AND);
event.register(PPEntityTypes.PIGLIN_TRAVELER.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, PiglinTraveler::checkTravelerSpawnRules, RegisterSpawnPlacementsEvent.Operation.AND);
}

private void setup(final FMLCommonSetupEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public CommonConfig(ModConfigSpec.Builder builder) {
BangBlockDestruction = builder.define("Have the explosion spawned while using the Bang! enchant destroy blocks?", false);
BruteBuckler = builder.define("Have brutes spawn with bucklers?", true);
bucklerCooldown = builder.defineInRange("How long should the buckler's cooldown be in ticks?", 240, Integer.MIN_VALUE, Integer.MAX_VALUE);
minBucklerChargeTime = builder.defineInRange("How long should the buckler's charge move be in ticks?", 15, Integer.MIN_VALUE, Integer.MAX_VALUE); // Thinking of removing this in 1.17.
minBucklerChargeTime = builder.defineInRange("How long should the buckler's charge move be in ticks?", 15, Integer.MIN_VALUE, Integer.MAX_VALUE);
maxBucklerChargeTime = builder.defineInRange("How long should the buckler's charge move if you have the max level of turning enchant be in ticks?", 40, Integer.MIN_VALUE, Integer.MAX_VALUE);
bucklerChance = builder.defineInRange("Chance of buckler appearing in bastion loot", 0.25F, 0.0F, 9999999.0F);
turningBucklerLaunchStrength = builder.comment("Experimental: Bucklers enchanted with Turning will allow the player to launch off of blocks they collide with. By default this is disabled, but if you want to test it out try 0.15").defineInRange("Launch strength ", 0.0D, 0.0D, 999999.0D);
turningBucklerLaunchStrength = builder.comment("Experimental: Bucklers enchanted with Turning will allow the player to launch off of blocks they collide with.").defineInRange("Launch strength ", 0.15D, 0.0D, 999999.0D);
builder.pop();
builder.push("Piglin Alchemist");
alchemistPotionChance = builder.defineInRange("Chance of alchemist potions not getting broken when killed", 0.20F, 0.0F, 9000.0F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
import net.neoforged.neoforge.common.util.InsertableLinkedOpenCustomHashSet;
import net.neoforged.neoforge.common.util.MutableHashedLinkedMap;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;

import java.util.function.Function;

public class RegistryUtilities {
public static void addToCreativeTabAfter(MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> creativeTab, Item after, Item... toAdd) {
public static void addToCreativeTabAfter(BuildCreativeModeTabContentsEvent event, Item after, Item... toAdd) {
if (toAdd.length > 0) {
creativeTab.putAfter(new ItemStack(after), new ItemStack(toAdd[0]), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
event.insertAfter(new ItemStack(after), new ItemStack(toAdd[0]), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
if (toAdd.length > 1)
for (int i = 1; i < toAdd.length; i++)
creativeTab.putAfter(new ItemStack(toAdd[i - 1]), new ItemStack(toAdd[i]), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
event.insertAfter(new ItemStack(toAdd[i - 1]), new ItemStack(toAdd[i]), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
}
}

Expand Down

0 comments on commit 46b9c55

Please sign in to comment.