Skip to content

Instantly share code, notes, and snippets.

@daekgorsel
Last active Jul 27, 2021
Embed
What would you like to do?
@Mod.EventBusSubscriber(modid = LavaArmor.MODID, bus = Bus.MOD, value = Dist.CLIENT)
public class ClientEventBusSubscriber {
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void registerRenderers(final FMLClientSetupEvent event)
{
GeoArmorRenderer.registerArmorRenderer(HotLavaItem.class, new HotLavaRenderer());
}
}
public class EventHandler {
@SubscribeEvent
public static void onLivingAttackEvent(LivingAttackEvent event)
{
if (event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == ItemInit.LAVA_HELMET.get()
&& event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == ItemInit.LAVA_CHEST.get()
&& event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == ItemInit.LAVA_LEGGINGS.get()
&& event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == ItemInit.LAVA_BOOTS.get())
{
//event.getSource().getTrueSource().getEntity().onKillCommand();
if (event.getSource().getTrueSource().getEntity() instanceof MobEntity)
{
event.getSource().getTrueSource().getEntity().onKillCommand();
}
}
}
}
public class HotLavaItem extends GeoArmorItem implements IAnimatable
{
private AnimationFactory factory = new AnimationFactory(this);
public HotLavaItem(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder)
{
super(materialIn, slot, builder.group(ItemGroup.COMBAT));
}
private <P extends IAnimatable> PlayState predicate(AnimationEvent<P> event)
{
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.lavaarmor.idle", true));
return PlayState.CONTINUE;
}
@Override
public void registerControllers(AnimationData data)
{
data.addAnimationController(new AnimationController(this, "controller", 20, this::predicate));
}
@Override
public AnimationFactory getFactory()
{
return this.factory;
}
}
public class HotLavaModel extends AnimatedGeoModel<HotLavaItem>
{
@Override
public ResourceLocation getModelLocation(HotLavaItem object)
{
return new ResourceLocation(LavaArmor.MODID, "geo/lava.geo.json");
}
@Override
public ResourceLocation getTextureLocation(HotLavaItem object)
{
return new ResourceLocation(LavaArmor.MODID, "textures/item/lava.png");
}
@Override
public ResourceLocation getAnimationFileLocation(HotLavaItem object)
{
return new ResourceLocation(LavaArmor.MODID, "animations/lava.animation.json");
}
}
public class HotLavaRenderer extends GeoArmorRenderer<HotLavaItem>
{
public HotLavaRenderer()
{
super(new HotLavaModel());
//These values are what each bone name is in blockbench. So if your head bone is named "bone545",
// make sure to do this.headBone = "bone545";
// The default values are the ones that come with the default armor template in the geckolib blockbench plugin.
this.headBone = "helmet";
this.bodyBone = "chestplate";
this.rightArmBone = "rightArm";
this.leftArmBone = "leftArm";
this.rightLegBone = "rightLeg";
this.leftLegBone = "leftLeg";
this.rightBootBone = "rightBoot";
this.leftBootBone = "leftBoot";
}
}
public class ItemInit {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS,
LavaArmor.MODID);
public static final RegistryObject<Item> JADE_INGOT = ITEMS.register("jade_ingot",
() -> new Item(new Item.Properties().group(ItemGroup.COMBAT)));
public static final RegistryObject<Item> LAVA_BOOTS = ITEMS.register("lava_boots",
() -> new HotLavaItem(LavaMaterial.LAVA_ARMOR, EquipmentSlotType.FEET,
new Item.Properties().group(ItemGroup.COMBAT)));
public static final RegistryObject<Item> LAVA_LEGGINGS = ITEMS.register("lava_leggings",
() -> new HotLavaItem(LavaMaterial.LAVA_ARMOR, EquipmentSlotType.LEGS,
new Item.Properties().group(ItemGroup.COMBAT)));
public static final RegistryObject<Item> LAVA_CHEST = ITEMS.register("lava_chest",
() -> new HotLavaItem(LavaMaterial.LAVA_ARMOR, EquipmentSlotType.CHEST,
new Item.Properties().group(ItemGroup.COMBAT)));
public static final RegistryObject<Item> LAVA_HELMET = ITEMS.register("lava_helmet",
() -> new HotLavaItem(LavaMaterial.LAVA_ARMOR, EquipmentSlotType.HEAD,
new Item.Properties().group(ItemGroup.COMBAT)));
}
@Mod(LavaArmor.MODID)
public class LavaArmor {
public static final String MODID = "lavaarmor";
public LavaArmor() {
GeckoLib.initialize();
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
bus.addListener(this::setup);
ItemInit.ITEMS.register(bus);
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(EventHandler.class);
}
@SuppressWarnings("deprecation")
private void setup(final FMLCommonSetupEvent event) {
DeferredWorkQueue.runLater(() -> {
//GlobalEntityTypeAttributes.put(EntityTypeInit.EXAMPLE.get(), ExampleEntity.setAttributes().create());
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment