initial commit
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* MCreator note:
|
||||
*
|
||||
* If you lock base mod element files, you can edit this file and the proxy files
|
||||
* and they won't get overwritten. If you change your mod package or modid, you
|
||||
* need to apply these changes to this file MANUALLY.
|
||||
*
|
||||
* Settings in @Mod annotation WON'T be changed in case of the base mod element
|
||||
* files lock too, so you need to set them manually here in such case.
|
||||
*
|
||||
* Keep the HemModElements object in this class and all calls to this object
|
||||
* INTACT in order to preserve functionality of mod elements generated by MCreator.
|
||||
*
|
||||
* If you do not lock base mod element files in Workspace settings, this file
|
||||
* will be REGENERATED on each build.
|
||||
*
|
||||
*/
|
||||
package studio.halbear.hem;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod("hem")
|
||||
public class HemMod {
|
||||
public static final Logger LOGGER = LogManager.getLogger(HemMod.class);
|
||||
private static final String PROTOCOL_VERSION = "1";
|
||||
public static final SimpleChannel PACKET_HANDLER = NetworkRegistry.newSimpleChannel(new ResourceLocation("hem", "hem"), () -> PROTOCOL_VERSION,
|
||||
PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
|
||||
public HemModElements elements;
|
||||
|
||||
public HemMod() {
|
||||
elements = new HemModElements();
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientLoad);
|
||||
MinecraftForge.EVENT_BUS.register(new HemModFMLBusEvents(this));
|
||||
}
|
||||
|
||||
private void init(FMLCommonSetupEvent event) {
|
||||
elements.getElements().forEach(element -> element.init(event));
|
||||
}
|
||||
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
elements.getElements().forEach(element -> element.clientLoad(event));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerBlocks(RegistryEvent.Register<Block> event) {
|
||||
event.getRegistry().registerAll(elements.getBlocks().stream().map(Supplier::get).toArray(Block[]::new));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerItems(RegistryEvent.Register<Item> event) {
|
||||
event.getRegistry().registerAll(elements.getItems().stream().map(Supplier::get).toArray(Item[]::new));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
|
||||
event.getRegistry().registerAll(elements.getEntities().stream().map(Supplier::get).toArray(EntityType[]::new));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerEnchantments(RegistryEvent.Register<Enchantment> event) {
|
||||
event.getRegistry().registerAll(elements.getEnchantments().stream().map(Supplier::get).toArray(Enchantment[]::new));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerSounds(RegistryEvent.Register<net.minecraft.util.SoundEvent> event) {
|
||||
elements.registerSounds(event);
|
||||
}
|
||||
|
||||
private static class HemModFMLBusEvents {
|
||||
private final HemMod parent;
|
||||
|
||||
HemModFMLBusEvents(HemMod parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverLoad(FMLServerStartingEvent event) {
|
||||
this.parent.elements.getElements().forEach(element -> element.serverLoad(event));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* MCreator note:
|
||||
*
|
||||
* This file is autogenerated to connect all MCreator mod elements together.
|
||||
*
|
||||
*/
|
||||
package studio.halbear.hem;
|
||||
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
public class HemModElements {
|
||||
public final List<ModElement> elements = new ArrayList<>();
|
||||
public final List<Supplier<Block>> blocks = new ArrayList<>();
|
||||
public final List<Supplier<Item>> items = new ArrayList<>();
|
||||
public final List<Supplier<EntityType<?>>> entities = new ArrayList<>();
|
||||
public final List<Supplier<Enchantment>> enchantments = new ArrayList<>();
|
||||
public static Map<ResourceLocation, net.minecraft.util.SoundEvent> sounds = new HashMap<>();
|
||||
|
||||
public HemModElements() {
|
||||
try {
|
||||
ModFileScanData modFileInfo = ModList.get().getModFileById("hem").getFile().getScanResult();
|
||||
Set<ModFileScanData.AnnotationData> annotations = modFileInfo.getAnnotations();
|
||||
for (ModFileScanData.AnnotationData annotationData : annotations) {
|
||||
if (annotationData.getAnnotationType().getClassName().equals(ModElement.Tag.class.getName())) {
|
||||
Class<?> clazz = Class.forName(annotationData.getClassType().getClassName());
|
||||
if (clazz.getSuperclass() == HemModElements.ModElement.class)
|
||||
elements.add((HemModElements.ModElement) clazz.getConstructor(this.getClass()).newInstance(this));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Collections.sort(elements);
|
||||
elements.forEach(HemModElements.ModElement::initElements);
|
||||
MinecraftForge.EVENT_BUS.register(new HemModVariables(this));
|
||||
}
|
||||
|
||||
public void registerSounds(RegistryEvent.Register<net.minecraft.util.SoundEvent> event) {
|
||||
for (Map.Entry<ResourceLocation, net.minecraft.util.SoundEvent> sound : sounds.entrySet())
|
||||
event.getRegistry().register(sound.getValue().setRegistryName(sound.getKey()));
|
||||
}
|
||||
|
||||
private int messageID = 0;
|
||||
|
||||
public <T> void addNetworkMessage(Class<T> messageType, BiConsumer<T, PacketBuffer> encoder, Function<PacketBuffer, T> decoder,
|
||||
BiConsumer<T, Supplier<NetworkEvent.Context>> messageConsumer) {
|
||||
HemMod.PACKET_HANDLER.registerMessage(messageID, messageType, encoder, decoder, messageConsumer);
|
||||
messageID++;
|
||||
}
|
||||
|
||||
public List<ModElement> getElements() {
|
||||
return elements;
|
||||
}
|
||||
|
||||
public List<Supplier<Block>> getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public List<Supplier<Item>> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<Supplier<EntityType<?>>> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public List<Supplier<Enchantment>> getEnchantments() {
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
public static class ModElement implements Comparable<ModElement> {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Tag {
|
||||
}
|
||||
|
||||
protected final HemModElements elements;
|
||||
protected final int sortid;
|
||||
|
||||
public ModElement(HemModElements elements, int sortid) {
|
||||
this.elements = elements;
|
||||
this.sortid = sortid;
|
||||
}
|
||||
|
||||
public void initElements() {
|
||||
}
|
||||
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
public void serverLoad(FMLServerStartingEvent event) {
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ModElement other) {
|
||||
return this.sortid - other.sortid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
package studio.halbear.hem;
|
||||
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IServerWorld;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class HemModVariables {
|
||||
public HemModVariables(HemModElements elements) {
|
||||
elements.addNetworkMessage(WorldSavedDataSyncMessage.class, WorldSavedDataSyncMessage::buffer, WorldSavedDataSyncMessage::new,
|
||||
WorldSavedDataSyncMessage::handler);
|
||||
elements.addNetworkMessage(PlayerVariablesSyncMessage.class, PlayerVariablesSyncMessage::buffer, PlayerVariablesSyncMessage::new,
|
||||
PlayerVariablesSyncMessage::handler);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init);
|
||||
}
|
||||
|
||||
private void init(FMLCommonSetupEvent event) {
|
||||
CapabilityManager.INSTANCE.register(PlayerVariables.class, new PlayerVariablesStorage(), PlayerVariables::new);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (!event.getPlayer().world.isRemote()) {
|
||||
WorldSavedData mapdata = MapVariables.get(event.getPlayer().world);
|
||||
WorldSavedData worlddata = WorldVariables.get(event.getPlayer().world);
|
||||
if (mapdata != null)
|
||||
HemMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()),
|
||||
new WorldSavedDataSyncMessage(0, mapdata));
|
||||
if (worlddata != null)
|
||||
HemMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()),
|
||||
new WorldSavedDataSyncMessage(1, worlddata));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
if (!event.getPlayer().world.isRemote()) {
|
||||
WorldSavedData worlddata = WorldVariables.get(event.getPlayer().world);
|
||||
if (worlddata != null)
|
||||
HemMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) event.getPlayer()),
|
||||
new WorldSavedDataSyncMessage(1, worlddata));
|
||||
}
|
||||
}
|
||||
|
||||
public static class WorldVariables extends WorldSavedData {
|
||||
public static final String DATA_NAME = "hem_worldvars";
|
||||
public boolean EmberleafMilitaryDefeated = false;
|
||||
public double VehicleID = 0;
|
||||
|
||||
public WorldVariables() {
|
||||
super(DATA_NAME);
|
||||
}
|
||||
|
||||
public WorldVariables(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT nbt) {
|
||||
EmberleafMilitaryDefeated = nbt.getBoolean("EmberleafMilitaryDefeated");
|
||||
VehicleID = nbt.getDouble("VehicleID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT nbt) {
|
||||
nbt.putBoolean("EmberleafMilitaryDefeated", EmberleafMilitaryDefeated);
|
||||
nbt.putDouble("VehicleID", VehicleID);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void syncData(IWorld world) {
|
||||
this.markDirty();
|
||||
if (world instanceof World && !world.isRemote())
|
||||
HemMod.PACKET_HANDLER.send(PacketDistributor.DIMENSION.with(((World) world)::getDimensionKey),
|
||||
new WorldSavedDataSyncMessage(1, this));
|
||||
}
|
||||
|
||||
static WorldVariables clientSide = new WorldVariables();
|
||||
|
||||
public static WorldVariables get(IWorld world) {
|
||||
if (world instanceof ServerWorld) {
|
||||
return ((ServerWorld) world).getSavedData().getOrCreate(WorldVariables::new, DATA_NAME);
|
||||
} else {
|
||||
return clientSide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapVariables extends WorldSavedData {
|
||||
public static final String DATA_NAME = "hem_mapvars";
|
||||
|
||||
public MapVariables() {
|
||||
super(DATA_NAME);
|
||||
}
|
||||
|
||||
public MapVariables(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT nbt) {
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void syncData(IWorld world) {
|
||||
this.markDirty();
|
||||
if (world instanceof World && !world.isRemote())
|
||||
HemMod.PACKET_HANDLER.send(PacketDistributor.ALL.noArg(), new WorldSavedDataSyncMessage(0, this));
|
||||
}
|
||||
|
||||
static MapVariables clientSide = new MapVariables();
|
||||
|
||||
public static MapVariables get(IWorld world) {
|
||||
if (world instanceof IServerWorld) {
|
||||
return ((IServerWorld) world).getWorld().getServer().getWorld(World.OVERWORLD).getSavedData().getOrCreate(MapVariables::new,
|
||||
DATA_NAME);
|
||||
} else {
|
||||
return clientSide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class WorldSavedDataSyncMessage {
|
||||
public int type;
|
||||
public WorldSavedData data;
|
||||
|
||||
public WorldSavedDataSyncMessage(PacketBuffer buffer) {
|
||||
this.type = buffer.readInt();
|
||||
this.data = this.type == 0 ? new MapVariables() : new WorldVariables();
|
||||
this.data.read(buffer.readCompoundTag());
|
||||
}
|
||||
|
||||
public WorldSavedDataSyncMessage(int type, WorldSavedData data) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static void buffer(WorldSavedDataSyncMessage message, PacketBuffer buffer) {
|
||||
buffer.writeInt(message.type);
|
||||
buffer.writeCompoundTag(message.data.write(new CompoundNBT()));
|
||||
}
|
||||
|
||||
public static void handler(WorldSavedDataSyncMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
if (!context.getDirection().getReceptionSide().isServer()) {
|
||||
if (message.type == 0)
|
||||
MapVariables.clientSide = (MapVariables) message.data;
|
||||
else
|
||||
WorldVariables.clientSide = (WorldVariables) message.data;
|
||||
}
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@CapabilityInject(PlayerVariables.class)
|
||||
public static Capability<PlayerVariables> PLAYER_VARIABLES_CAPABILITY = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
||||
if (event.getObject() instanceof PlayerEntity && !(event.getObject() instanceof FakePlayer))
|
||||
event.addCapability(new ResourceLocation("hem", "player_variables"), new PlayerVariablesProvider());
|
||||
}
|
||||
|
||||
private static class PlayerVariablesProvider implements ICapabilitySerializable<INBT> {
|
||||
private final LazyOptional<PlayerVariables> instance = LazyOptional.of(PLAYER_VARIABLES_CAPABILITY::getDefaultInstance);
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
|
||||
return cap == PLAYER_VARIABLES_CAPABILITY ? instance.cast() : LazyOptional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public INBT serializeNBT() {
|
||||
return PLAYER_VARIABLES_CAPABILITY.getStorage().writeNBT(PLAYER_VARIABLES_CAPABILITY, this.instance.orElseThrow(RuntimeException::new),
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(INBT nbt) {
|
||||
PLAYER_VARIABLES_CAPABILITY.getStorage().readNBT(PLAYER_VARIABLES_CAPABILITY, this.instance.orElseThrow(RuntimeException::new), null,
|
||||
nbt);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PlayerVariablesStorage implements Capability.IStorage<PlayerVariables> {
|
||||
@Override
|
||||
public INBT writeNBT(Capability<PlayerVariables> capability, PlayerVariables instance, Direction side) {
|
||||
CompoundNBT nbt = new CompoundNBT();
|
||||
nbt.putDouble("BodyTemperature", instance.BodyTemperature);
|
||||
nbt.putBoolean("DisableClientSideBlocks", instance.DisableClientSideBlocks);
|
||||
nbt.putBoolean("Eaten", instance.Eaten);
|
||||
nbt.putDouble("Fuel", instance.Fuel);
|
||||
nbt.putDouble("GoalMPH", instance.GoalMPH);
|
||||
nbt.putDouble("GooCooldown", instance.GooCooldown);
|
||||
nbt.putDouble("Heat", instance.Heat);
|
||||
nbt.putDouble("LastPlantTrapX", instance.LastPlantTrapX);
|
||||
nbt.putDouble("LastPlantTrapY", instance.LastPlantTrapY);
|
||||
nbt.putDouble("LastPlantTrapZ", instance.LastPlantTrapZ);
|
||||
nbt.putDouble("LastPosX", instance.LastPosX);
|
||||
nbt.putDouble("LastPosZ", instance.LastPosZ);
|
||||
nbt.putDouble("MPH", instance.MPH);
|
||||
nbt.putBoolean("PilotingVehicle", instance.PilotingVehicle);
|
||||
nbt.putDouble("PilotingVehicleID", instance.PilotingVehicleID);
|
||||
nbt.putDouble("PSI", instance.PSI);
|
||||
nbt.putDouble("Speed", instance.Speed);
|
||||
nbt.putBoolean("VehicleAccelerate", instance.VehicleAccelerate);
|
||||
nbt.putBoolean("VehicleBackward", instance.VehicleBackward);
|
||||
nbt.putBoolean("VehicleDecelerate", instance.VehicleDecelerate);
|
||||
nbt.putBoolean("VehicleForward", instance.VehicleForward);
|
||||
nbt.putBoolean("VehicleIncreasePressure", instance.VehicleIncreasePressure);
|
||||
nbt.putDouble("VehicleOdometer", instance.VehicleOdometer);
|
||||
nbt.putDouble("VehicleOdometerMetres", instance.VehicleOdometerMetres);
|
||||
nbt.putBoolean("VehicleReleasePressure", instance.VehicleReleasePressure);
|
||||
nbt.putBoolean("VehicleStrafeLeft", instance.VehicleStrafeLeft);
|
||||
nbt.putBoolean("VehicleStrafeRight", instance.VehicleStrafeRight);
|
||||
nbt.putBoolean("VehicleTurnLeft", instance.VehicleTurnLeft);
|
||||
nbt.putBoolean("VehicleTurnRight", instance.VehicleTurnRight);
|
||||
nbt.putDouble("VehicleYaw", instance.VehicleYaw);
|
||||
nbt.putDouble("Altimeter", instance.Altimeter);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<PlayerVariables> capability, PlayerVariables instance, Direction side, INBT inbt) {
|
||||
CompoundNBT nbt = (CompoundNBT) inbt;
|
||||
instance.BodyTemperature = nbt.getDouble("BodyTemperature");
|
||||
instance.DisableClientSideBlocks = nbt.getBoolean("DisableClientSideBlocks");
|
||||
instance.Eaten = nbt.getBoolean("Eaten");
|
||||
instance.Fuel = nbt.getDouble("Fuel");
|
||||
instance.GoalMPH = nbt.getDouble("GoalMPH");
|
||||
instance.GooCooldown = nbt.getDouble("GooCooldown");
|
||||
instance.Heat = nbt.getDouble("Heat");
|
||||
instance.LastPlantTrapX = nbt.getDouble("LastPlantTrapX");
|
||||
instance.LastPlantTrapY = nbt.getDouble("LastPlantTrapY");
|
||||
instance.LastPlantTrapZ = nbt.getDouble("LastPlantTrapZ");
|
||||
instance.LastPosX = nbt.getDouble("LastPosX");
|
||||
instance.LastPosZ = nbt.getDouble("LastPosZ");
|
||||
instance.MPH = nbt.getDouble("MPH");
|
||||
instance.PilotingVehicle = nbt.getBoolean("PilotingVehicle");
|
||||
instance.PilotingVehicleID = nbt.getDouble("PilotingVehicleID");
|
||||
instance.PSI = nbt.getDouble("PSI");
|
||||
instance.Speed = nbt.getDouble("Speed");
|
||||
instance.VehicleAccelerate = nbt.getBoolean("VehicleAccelerate");
|
||||
instance.VehicleBackward = nbt.getBoolean("VehicleBackward");
|
||||
instance.VehicleDecelerate = nbt.getBoolean("VehicleDecelerate");
|
||||
instance.VehicleForward = nbt.getBoolean("VehicleForward");
|
||||
instance.VehicleIncreasePressure = nbt.getBoolean("VehicleIncreasePressure");
|
||||
instance.VehicleOdometer = nbt.getDouble("VehicleOdometer");
|
||||
instance.VehicleOdometerMetres = nbt.getDouble("VehicleOdometerMetres");
|
||||
instance.VehicleReleasePressure = nbt.getBoolean("VehicleReleasePressure");
|
||||
instance.VehicleStrafeLeft = nbt.getBoolean("VehicleStrafeLeft");
|
||||
instance.VehicleStrafeRight = nbt.getBoolean("VehicleStrafeRight");
|
||||
instance.VehicleTurnLeft = nbt.getBoolean("VehicleTurnLeft");
|
||||
instance.VehicleTurnRight = nbt.getBoolean("VehicleTurnRight");
|
||||
instance.VehicleYaw = nbt.getDouble("VehicleYaw");
|
||||
instance.Altimeter = nbt.getDouble("Altimeter");
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerVariables {
|
||||
public double BodyTemperature = 37.0;
|
||||
public boolean DisableClientSideBlocks = false;
|
||||
public boolean Eaten = false;
|
||||
public double Fuel = 0;
|
||||
public double GoalMPH = 0;
|
||||
public double GooCooldown = 0;
|
||||
public double Heat = 0;
|
||||
public double LastPlantTrapX = 0;
|
||||
public double LastPlantTrapY = 0;
|
||||
public double LastPlantTrapZ = 0;
|
||||
public double LastPosX = 0;
|
||||
public double LastPosZ = 0;
|
||||
public double MPH = 0;
|
||||
public boolean PilotingVehicle = false;
|
||||
public double PilotingVehicleID = 0;
|
||||
public double PSI = 0;
|
||||
public double Speed = 0;
|
||||
public boolean VehicleAccelerate = false;
|
||||
public boolean VehicleBackward = false;
|
||||
public boolean VehicleDecelerate = false;
|
||||
public boolean VehicleForward = false;
|
||||
public boolean VehicleIncreasePressure = false;
|
||||
public double VehicleOdometer = 0;
|
||||
public double VehicleOdometerMetres = 0;
|
||||
public boolean VehicleReleasePressure = false;
|
||||
public boolean VehicleStrafeLeft = false;
|
||||
public boolean VehicleStrafeRight = false;
|
||||
public boolean VehicleTurnLeft = false;
|
||||
public boolean VehicleTurnRight = false;
|
||||
public double VehicleYaw = 0;
|
||||
public double Altimeter = 0;
|
||||
|
||||
public void syncPlayerVariables(Entity entity) {
|
||||
if (entity instanceof ServerPlayerEntity)
|
||||
HemMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) entity), new PlayerVariablesSyncMessage(this));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerLoggedInSyncPlayerVariables(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (!event.getPlayer().world.isRemote())
|
||||
((PlayerVariables) event.getPlayer().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()))
|
||||
.syncPlayerVariables(event.getPlayer());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerRespawnedSyncPlayerVariables(PlayerEvent.PlayerRespawnEvent event) {
|
||||
if (!event.getPlayer().world.isRemote())
|
||||
((PlayerVariables) event.getPlayer().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()))
|
||||
.syncPlayerVariables(event.getPlayer());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerChangedDimensionSyncPlayerVariables(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
if (!event.getPlayer().world.isRemote())
|
||||
((PlayerVariables) event.getPlayer().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()))
|
||||
.syncPlayerVariables(event.getPlayer());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clonePlayer(PlayerEvent.Clone event) {
|
||||
PlayerVariables original = ((PlayerVariables) event.getOriginal().getCapability(PLAYER_VARIABLES_CAPABILITY, null)
|
||||
.orElse(new PlayerVariables()));
|
||||
PlayerVariables clone = ((PlayerVariables) event.getEntity().getCapability(PLAYER_VARIABLES_CAPABILITY, null).orElse(new PlayerVariables()));
|
||||
clone.BodyTemperature = original.BodyTemperature;
|
||||
clone.DisableClientSideBlocks = original.DisableClientSideBlocks;
|
||||
clone.Eaten = original.Eaten;
|
||||
clone.Fuel = original.Fuel;
|
||||
clone.GoalMPH = original.GoalMPH;
|
||||
clone.GooCooldown = original.GooCooldown;
|
||||
clone.Heat = original.Heat;
|
||||
clone.LastPlantTrapX = original.LastPlantTrapX;
|
||||
clone.LastPlantTrapY = original.LastPlantTrapY;
|
||||
clone.LastPlantTrapZ = original.LastPlantTrapZ;
|
||||
clone.LastPosX = original.LastPosX;
|
||||
clone.LastPosZ = original.LastPosZ;
|
||||
clone.MPH = original.MPH;
|
||||
clone.PilotingVehicle = original.PilotingVehicle;
|
||||
clone.PilotingVehicleID = original.PilotingVehicleID;
|
||||
clone.PSI = original.PSI;
|
||||
clone.Speed = original.Speed;
|
||||
clone.VehicleAccelerate = original.VehicleAccelerate;
|
||||
clone.VehicleBackward = original.VehicleBackward;
|
||||
clone.VehicleDecelerate = original.VehicleDecelerate;
|
||||
clone.VehicleForward = original.VehicleForward;
|
||||
clone.VehicleIncreasePressure = original.VehicleIncreasePressure;
|
||||
clone.VehicleOdometer = original.VehicleOdometer;
|
||||
clone.VehicleOdometerMetres = original.VehicleOdometerMetres;
|
||||
clone.VehicleReleasePressure = original.VehicleReleasePressure;
|
||||
clone.VehicleStrafeLeft = original.VehicleStrafeLeft;
|
||||
clone.VehicleStrafeRight = original.VehicleStrafeRight;
|
||||
clone.VehicleTurnLeft = original.VehicleTurnLeft;
|
||||
clone.VehicleTurnRight = original.VehicleTurnRight;
|
||||
clone.VehicleYaw = original.VehicleYaw;
|
||||
clone.Altimeter = original.Altimeter;
|
||||
if (!event.isWasDeath()) {
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerVariablesSyncMessage {
|
||||
public PlayerVariables data;
|
||||
|
||||
public PlayerVariablesSyncMessage(PacketBuffer buffer) {
|
||||
this.data = new PlayerVariables();
|
||||
new PlayerVariablesStorage().readNBT(null, this.data, null, buffer.readCompoundTag());
|
||||
}
|
||||
|
||||
public PlayerVariablesSyncMessage(PlayerVariables data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static void buffer(PlayerVariablesSyncMessage message, PacketBuffer buffer) {
|
||||
buffer.writeCompoundTag((CompoundNBT) new PlayerVariablesStorage().writeNBT(null, message.data, null));
|
||||
}
|
||||
|
||||
public static void handler(PlayerVariablesSyncMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
if (!context.getDirection().getReceptionSide().isServer()) {
|
||||
PlayerVariables variables = ((PlayerVariables) Minecraft.getInstance().player.getCapability(PLAYER_VARIABLES_CAPABILITY, null)
|
||||
.orElse(new PlayerVariables()));
|
||||
variables.BodyTemperature = message.data.BodyTemperature;
|
||||
variables.DisableClientSideBlocks = message.data.DisableClientSideBlocks;
|
||||
variables.Eaten = message.data.Eaten;
|
||||
variables.Fuel = message.data.Fuel;
|
||||
variables.GoalMPH = message.data.GoalMPH;
|
||||
variables.GooCooldown = message.data.GooCooldown;
|
||||
variables.Heat = message.data.Heat;
|
||||
variables.LastPlantTrapX = message.data.LastPlantTrapX;
|
||||
variables.LastPlantTrapY = message.data.LastPlantTrapY;
|
||||
variables.LastPlantTrapZ = message.data.LastPlantTrapZ;
|
||||
variables.LastPosX = message.data.LastPosX;
|
||||
variables.LastPosZ = message.data.LastPosZ;
|
||||
variables.MPH = message.data.MPH;
|
||||
variables.PilotingVehicle = message.data.PilotingVehicle;
|
||||
variables.PilotingVehicleID = message.data.PilotingVehicleID;
|
||||
variables.PSI = message.data.PSI;
|
||||
variables.Speed = message.data.Speed;
|
||||
variables.VehicleAccelerate = message.data.VehicleAccelerate;
|
||||
variables.VehicleBackward = message.data.VehicleBackward;
|
||||
variables.VehicleDecelerate = message.data.VehicleDecelerate;
|
||||
variables.VehicleForward = message.data.VehicleForward;
|
||||
variables.VehicleIncreasePressure = message.data.VehicleIncreasePressure;
|
||||
variables.VehicleOdometer = message.data.VehicleOdometer;
|
||||
variables.VehicleOdometerMetres = message.data.VehicleOdometerMetres;
|
||||
variables.VehicleReleasePressure = message.data.VehicleReleasePressure;
|
||||
variables.VehicleStrafeLeft = message.data.VehicleStrafeLeft;
|
||||
variables.VehicleStrafeRight = message.data.VehicleStrafeRight;
|
||||
variables.VehicleTurnLeft = message.data.VehicleTurnLeft;
|
||||
variables.VehicleTurnRight = message.data.VehicleTurnRight;
|
||||
variables.VehicleYaw = message.data.VehicleYaw;
|
||||
variables.Altimeter = message.data.Altimeter;
|
||||
}
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.AntHillUpdateTickProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.pathfinding.PathNodeType;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class AntHillBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:ant_hill")
|
||||
public static final Block block = null;
|
||||
|
||||
public AntHillBlock(HemModElements instance) {
|
||||
super(instance, 34);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.EARTH).sound(SoundType.GROUND).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.SHOVEL).setRequiresTool().notSolid().tickRandomly().setOpaque((bs, br, bp) -> false));
|
||||
setRegistryName("ant_hill");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(2, 0, 2, 14, 5, 14))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, MobEntity entity) {
|
||||
return PathNodeType.WALKABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block.OffsetType getOffsetType() {
|
||||
return Block.OffsetType.XZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(AntsBlock.block, (int) (2)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockstate, ServerWorld world, BlockPos pos, Random random) {
|
||||
super.tick(blockstate, world, pos, random);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
AntHillUpdateTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.AntsEntityWalksOnTheBlockProcedure;
|
||||
import studio.halbear.hem.procedures.AntsBlockAddedProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class AntsBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:ants")
|
||||
public static final Block block = null;
|
||||
|
||||
public AntsBlock(HemModElements instance) {
|
||||
super(instance, 35);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.PLANTS).sound(SoundType.BASALT).hardnessAndResistance(0.1f, 0f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.SHOVEL).speedFactor(0.8f).jumpFactor(0.9f).notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
|
||||
setRegistryName("ants");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
switch ((Direction) state.get(FACING)) {
|
||||
case SOUTH :
|
||||
default :
|
||||
return VoxelShapes.or(makeCuboidShape(16, 0, 16, 0, 1, 0))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case NORTH :
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 1, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case EAST :
|
||||
return VoxelShapes.or(makeCuboidShape(16, 0, 0, 0, 1, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case WEST :
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 16, 16, 1, 0))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
return state.with(FACING, rot.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext context) {
|
||||
return context.getItem().getItem() != this.asItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushReaction getPushReaction(BlockState state) {
|
||||
return PushReaction.DESTROY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(BlockState blockstate, World world, BlockPos pos, BlockState oldState, boolean moving) {
|
||||
super.onBlockAdded(blockstate, world, pos, oldState, moving);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
AntsBlockAddedProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
AntsEntityWalksOnTheBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityWalk(world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
BlockState blockstate = world.getBlockState(pos);
|
||||
|
||||
AntsEntityWalksOnTheBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.BulbFlowerPlantRightClickedProcedure;
|
||||
import studio.halbear.hem.procedures.BloomedBulbFlowerUpdateTickProcedure;
|
||||
import studio.halbear.hem.particle.LilyPadParticlesParticle;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BloomedBulbFlowerBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:bloomed_bulb_flower")
|
||||
public static final Block block = null;
|
||||
|
||||
public BloomedBulbFlowerBlock(HemModElements instance) {
|
||||
super(instance, 39);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.PLANTS).sound(SoundType.PLANT).hardnessAndResistance(1f, 1f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.HOE).doesNotBlockMovement().notSolid().tickRandomly().setOpaque((bs, br, bp) -> false));
|
||||
setRegistryName("bloomed_bulb_flower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(-5, 0, -5, 21, 3, 21))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockstate, ServerWorld world, BlockPos pos, Random random) {
|
||||
super.tick(blockstate, world, pos, random);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
BloomedBulbFlowerUpdateTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (true)
|
||||
for (int l = 0; l < 1; ++l) {
|
||||
double d0 = (x + 0.5) + (random.nextFloat() - 0.5) * 0.1D * 20;
|
||||
double d1 = ((y + 0.7) + (random.nextFloat() - 0.5) * 0.1D) + 0.5;
|
||||
double d2 = (z + 0.5) + (random.nextFloat() - 0.5) * 0.1D * 20;
|
||||
world.addParticle(LilyPadParticlesParticle.particle, d0, d1, d2, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
BulbFlowerPlantRightClickedProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.BloomedMuncherUpdateTickProcedure;
|
||||
import studio.halbear.hem.procedures.BloomedMuncherEntityCollidesInTheBlockProcedure;
|
||||
import studio.halbear.hem.particle.LilyPadParticlesParticle;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.LockableLootTileEntity;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ChestContainer;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BloomedMuncherBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:bloomed_muncher")
|
||||
public static final Block block = null;
|
||||
@ObjectHolder("hem:bloomed_muncher")
|
||||
public static final TileEntityType<CustomTileEntity> tileEntityType = null;
|
||||
|
||||
public BloomedMuncherBlock(HemModElements instance) {
|
||||
super(instance, 31);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new TileEntityRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
private static class TileEntityRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerTileEntity(RegistryEvent.Register<TileEntityType<?>> event) {
|
||||
event.getRegistry().register(TileEntityType.Builder.create(CustomTileEntity::new, block).build(null).setRegistryName("bloomed_muncher"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.PLANTS).sound(SoundType.PLANT).hardnessAndResistance(1f, 1f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.HOE).doesNotBlockMovement().notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
|
||||
setRegistryName("bloomed_muncher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
switch ((Direction) state.get(FACING)) {
|
||||
case SOUTH :
|
||||
default :
|
||||
return VoxelShapes.or(makeCuboidShape(21, 0, 21, -5, 3, -5))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case NORTH :
|
||||
return VoxelShapes.or(makeCuboidShape(-5, 0, -5, 21, 3, 21))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case EAST :
|
||||
return VoxelShapes.or(makeCuboidShape(21, 0, -5, -5, 3, 21))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case WEST :
|
||||
return VoxelShapes.or(makeCuboidShape(-5, 0, 21, 21, 3, -5))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
return state.with(FACING, rot.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(BlockState blockstate, World world, BlockPos pos, BlockState oldState, boolean moving) {
|
||||
super.onBlockAdded(blockstate, world, pos, oldState, moving);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
world.getPendingBlockTicks().scheduleTick(pos, this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockstate, ServerWorld world, BlockPos pos, Random random) {
|
||||
super.tick(blockstate, world, pos, random);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
BloomedMuncherUpdateTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
world.getPendingBlockTicks().scheduleTick(pos, this, 1);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (true)
|
||||
for (int l = 0; l < 1; ++l) {
|
||||
double d0 = (x + 0.5) + (random.nextFloat() - 0.5) * 0.1D * 20;
|
||||
double d1 = ((y + 0.7) + (random.nextFloat() - 0.5) * 0.1D) + 0.5;
|
||||
double d2 = (z + 0.5) + (random.nextFloat() - 0.5) * 0.1D * 20;
|
||||
world.addParticle(LilyPadParticlesParticle.particle, d0, d1, d2, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
BloomedMuncherEntityCollidesInTheBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public INamedContainerProvider getContainer(BlockState state, World worldIn, BlockPos pos) {
|
||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||
return tileEntity instanceof INamedContainerProvider ? (INamedContainerProvider) tileEntity : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return new CustomTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventReceived(BlockState state, World world, BlockPos pos, int eventID, int eventParam) {
|
||||
super.eventReceived(state, world, pos, eventID, eventParam);
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
if (tileentity instanceof CustomTileEntity) {
|
||||
InventoryHelper.dropInventoryItems(world, pos, (CustomTileEntity) tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
|
||||
super.onReplaced(state, world, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState blockState, World world, BlockPos pos) {
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
if (tileentity instanceof CustomTileEntity)
|
||||
return Container.calcRedstoneFromInventory((CustomTileEntity) tileentity);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTileEntity extends LockableLootTileEntity implements ISidedInventory {
|
||||
private NonNullList<ItemStack> stacks = NonNullList.<ItemStack>withSize(0, ItemStack.EMPTY);
|
||||
|
||||
protected CustomTileEntity() {
|
||||
super(tileEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(BlockState blockState, CompoundNBT compound) {
|
||||
super.read(blockState, compound);
|
||||
if (!this.checkLootAndRead(compound)) {
|
||||
this.stacks = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
|
||||
}
|
||||
ItemStackHelper.loadAllItems(compound, this.stacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT compound) {
|
||||
super.write(compound);
|
||||
if (!this.checkLootAndWrite(compound)) {
|
||||
ItemStackHelper.saveAllItems(compound, this.stacks);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SUpdateTileEntityPacket getUpdatePacket() {
|
||||
return new SUpdateTileEntityPacket(this.pos, 0, this.getUpdateTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT getUpdateTag() {
|
||||
return this.write(new CompoundNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
|
||||
this.read(this.getBlockState(), pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return stacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (ItemStack itemstack : this.stacks)
|
||||
if (!itemstack.isEmpty())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDefaultName() {
|
||||
return new StringTextComponent("bloomed_muncher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container createMenu(int id, PlayerInventory player) {
|
||||
return ChestContainer.createGeneric9X3(id, player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new StringTextComponent("Bloomed Muncher 'Flower'");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getItems() {
|
||||
return this.stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> stacks) {
|
||||
this.stacks = stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(Direction side) {
|
||||
return IntStream.range(0, this.getSizeInventory()).toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack stack, @Nullable Direction direction) {
|
||||
return this.isItemValidForSlot(index, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private final LazyOptional<? extends IItemHandler>[] handlers = SidedInvWrapper.create(this, Direction.values());
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (!this.removed && facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
return handlers[facing.ordinal()].cast();
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
for (LazyOptional<? extends IItemHandler> handler : handlers)
|
||||
handler.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafBlossomerBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_blossomer")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafBlossomerBlock(HemModElements instance) {
|
||||
super(instance, 30);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(64).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(5);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_blossomer"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_blossomer"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.JUMP_BOOST, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_blossomer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafBrownCapBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_brown_cap")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafBrownCapBlock(HemModElements instance) {
|
||||
super(instance, 50);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(16).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(5);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_brown_cap"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_brown_cap"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.REGENERATION, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_brown_cap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafButterSlumpBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_butter_slump")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafButterSlumpBlock(HemModElements instance) {
|
||||
super(instance, 49);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(64).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(5);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_butter_slump"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_butter_slump"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.JUMP_BOOST, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_butter_slump");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafCabbageFlowerBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_cabbage_flower")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafCabbageFlowerBlock(HemModElements instance) {
|
||||
super(instance, 46);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(64).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(5);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_cabbage_flower"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_cabbage_flower"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.RESISTANCE, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_cabbage_flower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.world.gen.feature.template.RuleTest;
|
||||
import net.minecraft.world.gen.feature.template.IRuleTestType;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.OreFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafCobblestoneBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_cobblestone")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafCobblestoneBlock(HemModElements instance) {
|
||||
super(instance, 10);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(0.75f, 10f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_cobblestone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private static Feature<OreFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
private static IRuleTestType<CustomRuleTest> CUSTOM_MATCH = null;
|
||||
|
||||
private static class CustomRuleTest extends RuleTest {
|
||||
static final CustomRuleTest INSTANCE = new CustomRuleTest();
|
||||
static final com.mojang.serialization.Codec<CustomRuleTest> codec = com.mojang.serialization.Codec.unit(() -> INSTANCE);
|
||||
|
||||
public boolean test(BlockState blockAt, Random random) {
|
||||
boolean blockCriteria = false;
|
||||
if (blockAt.getBlock() == BlueleafStoneBlock.block)
|
||||
blockCriteria = true;
|
||||
return blockCriteria;
|
||||
}
|
||||
|
||||
protected IRuleTestType<?> getType() {
|
||||
return CUSTOM_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
CUSTOM_MATCH = Registry.register(Registry.RULE_TEST, new ResourceLocation("hem:blueleaf_cobblestone_match"), () -> CustomRuleTest.codec);
|
||||
feature = new OreFeature(OreFeatureConfig.CODEC) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random rand, BlockPos pos, OreFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, rand, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(new OreFeatureConfig(CustomRuleTest.INSTANCE, block.getDefaultState(), 26)).range(256)
|
||||
.square().func_242731_b(24);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_cobblestone"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_cobblestone"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).add(() -> configuredFeature);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import net.minecraft.state.properties.SlabType;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafCobblestoneSlabBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_cobblestone_slab")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafCobblestoneSlabBlock(HemModElements instance) {
|
||||
super(instance, 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends SlabBlock {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(0.75f, 10f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_cobblestone_slab");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, state.get(TYPE) == SlabType.DOUBLE ? 2 : 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafCobblestoneStairsBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_cobblestone_stairs")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafCobblestoneStairsBlock(HemModElements instance) {
|
||||
super(instance, 11);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends StairsBlock {
|
||||
public CustomBlock() {
|
||||
super(() -> new Block(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(0.75f, 10f)
|
||||
.setLightLevel(s -> 0).harvestLevel(1).harvestTool(ToolType.PICKAXE).setRequiresTool()).getDefaultState(),
|
||||
Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(0.75f, 10f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_cobblestone_stairs");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.state.Property;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.WallHeight;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafCobblestoneWallBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_cobblestone_wall")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafCobblestoneWallBlock(HemModElements instance) {
|
||||
super(instance, 13);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends WallBlock {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(0.75f, 10f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_cobblestone_wall");
|
||||
}
|
||||
|
||||
private static final VoxelShape CENTER_POLE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_NORTH_SIDE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 0.0D, 9.0D, 16.0D, 9.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_SOUTH_SIDE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 16.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_WEST_SIDE_SHAPE = Block.makeCuboidShape(0.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_EAST_SIDE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 7.0D, 16.0D, 16.0D, 9.0D);
|
||||
|
||||
private boolean shouldConnect(BlockState state, boolean checkattach, Direction face) {
|
||||
boolean flag = state.getBlock() instanceof WallBlock
|
||||
|| state.getBlock() instanceof FenceGateBlock && FenceGateBlock.isParallel(state, face);
|
||||
return !cannotAttach(state.getBlock()) && checkattach || flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
IWorldReader iworldreader = context.getWorld();
|
||||
BlockPos blockpos = context.getPos();
|
||||
FluidState fluidstate = context.getWorld().getFluidState(context.getPos());
|
||||
BlockPos blockpos1 = blockpos.north();
|
||||
BlockPos blockpos2 = blockpos.east();
|
||||
BlockPos blockpos3 = blockpos.south();
|
||||
BlockPos blockpos4 = blockpos.west();
|
||||
BlockPos blockpos5 = blockpos.up();
|
||||
BlockState blockstate = iworldreader.getBlockState(blockpos1);
|
||||
BlockState blockstate1 = iworldreader.getBlockState(blockpos2);
|
||||
BlockState blockstate2 = iworldreader.getBlockState(blockpos3);
|
||||
BlockState blockstate3 = iworldreader.getBlockState(blockpos4);
|
||||
BlockState blockstate4 = iworldreader.getBlockState(blockpos5);
|
||||
boolean flag = this.shouldConnect(blockstate, blockstate.isSolidSide(iworldreader, blockpos1, Direction.SOUTH), Direction.SOUTH);
|
||||
boolean flag1 = this.shouldConnect(blockstate1, blockstate1.isSolidSide(iworldreader, blockpos2, Direction.WEST), Direction.WEST);
|
||||
boolean flag2 = this.shouldConnect(blockstate2, blockstate2.isSolidSide(iworldreader, blockpos3, Direction.NORTH), Direction.NORTH);
|
||||
boolean flag3 = this.shouldConnect(blockstate3, blockstate3.isSolidSide(iworldreader, blockpos4, Direction.EAST), Direction.EAST);
|
||||
BlockState blockstate5 = this.getDefaultState().with(WATERLOGGED, Boolean.valueOf(fluidstate.getFluid() == Fluids.WATER));
|
||||
return this.func_235626_a_(iworldreader, blockstate5, blockpos5, blockstate4, flag, flag1, flag2, flag3);
|
||||
}
|
||||
|
||||
@Override /**
|
||||
* Update the provided state given the provided neighbor facing and neighbor state, returning a new state. For example, fences make their connections to the passed in state if possible, and wet concrete powder immediately returns its solidified counterpart. Note that this method should ideally consider only the specific face passed in.
|
||||
*/
|
||||
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (stateIn.get(WATERLOGGED)) {
|
||||
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
|
||||
}
|
||||
if (facing == Direction.DOWN) {
|
||||
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
|
||||
} else {
|
||||
return facing == Direction.UP
|
||||
? this.func_235625_a_(worldIn, stateIn, facingPos, facingState)
|
||||
: this.func_235627_a_(worldIn, currentPos, stateIn, facingPos, facingState, facing);
|
||||
}
|
||||
}
|
||||
|
||||
private BlockState func_235625_a_(IWorldReader reader, BlockState state1, BlockPos pos, BlockState state2) {
|
||||
boolean flag = hasHeightForProperty(state1, WALL_HEIGHT_NORTH);
|
||||
boolean flag1 = hasHeightForProperty(state1, WALL_HEIGHT_EAST);
|
||||
boolean flag2 = hasHeightForProperty(state1, WALL_HEIGHT_SOUTH);
|
||||
boolean flag3 = hasHeightForProperty(state1, WALL_HEIGHT_WEST);
|
||||
return this.func_235626_a_(reader, state1, pos, state2, flag, flag1, flag2, flag3);
|
||||
}
|
||||
|
||||
private BlockState func_235627_a_(IWorldReader reader, BlockPos p_235627_2_, BlockState p_235627_3_, BlockPos p_235627_4_,
|
||||
BlockState p_235627_5_, Direction directionIn) {
|
||||
Direction direction = directionIn.getOpposite();
|
||||
boolean flag = directionIn == Direction.NORTH
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_NORTH);
|
||||
boolean flag1 = directionIn == Direction.EAST
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_EAST);
|
||||
boolean flag2 = directionIn == Direction.SOUTH
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_SOUTH);
|
||||
boolean flag3 = directionIn == Direction.WEST
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_WEST);
|
||||
BlockPos blockpos = p_235627_2_.up();
|
||||
BlockState blockstate = reader.getBlockState(blockpos);
|
||||
return this.func_235626_a_(reader, p_235627_3_, blockpos, blockstate, flag, flag1, flag2, flag3);
|
||||
}
|
||||
|
||||
private BlockState func_235626_a_(IWorldReader reader, BlockState state, BlockPos pos, BlockState collisionState, boolean connectedSouth,
|
||||
boolean connectedWest, boolean connectedNorth, boolean connectedEast) {
|
||||
VoxelShape voxelshape = collisionState.getCollisionShape(reader, pos).project(Direction.DOWN);
|
||||
BlockState blockstate = this.func_235630_a_(state, connectedSouth, connectedWest, connectedNorth, connectedEast, voxelshape);
|
||||
return blockstate.with(UP, Boolean.valueOf(this.func_235628_a_(blockstate, collisionState, voxelshape)));
|
||||
}
|
||||
|
||||
private BlockState func_235630_a_(BlockState state, boolean connectedSouth, boolean connectedWest, boolean connectedNorth,
|
||||
boolean connectedEast, VoxelShape shape) {
|
||||
return state.with(WALL_HEIGHT_NORTH, this.func_235633_a_(connectedSouth, shape, WALL_CONNECTION_NORTH_SIDE_SHAPE))
|
||||
.with(WALL_HEIGHT_EAST, this.func_235633_a_(connectedWest, shape, WALL_CONNECTION_EAST_SIDE_SHAPE))
|
||||
.with(WALL_HEIGHT_SOUTH, this.func_235633_a_(connectedNorth, shape, WALL_CONNECTION_SOUTH_SIDE_SHAPE))
|
||||
.with(WALL_HEIGHT_WEST, this.func_235633_a_(connectedEast, shape, WALL_CONNECTION_WEST_SIDE_SHAPE));
|
||||
}
|
||||
|
||||
private WallHeight func_235633_a_(boolean p_235633_1_, VoxelShape p_235633_2_, VoxelShape p_235633_3_) {
|
||||
if (p_235633_1_) {
|
||||
return compareShapes(p_235633_2_, p_235633_3_) ? WallHeight.TALL : WallHeight.LOW;
|
||||
} else {
|
||||
return WallHeight.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean func_235628_a_(BlockState p_235628_1_, BlockState p_235628_2_, VoxelShape shape) {
|
||||
boolean flag = p_235628_2_.getBlock() instanceof WallBlock && p_235628_2_.get(UP);
|
||||
if (flag) {
|
||||
return true;
|
||||
} else {
|
||||
WallHeight wallheight = p_235628_1_.get(WALL_HEIGHT_NORTH);
|
||||
WallHeight wallheight1 = p_235628_1_.get(WALL_HEIGHT_SOUTH);
|
||||
WallHeight wallheight2 = p_235628_1_.get(WALL_HEIGHT_EAST);
|
||||
WallHeight wallheight3 = p_235628_1_.get(WALL_HEIGHT_WEST);
|
||||
boolean flag1 = wallheight1 == WallHeight.NONE;
|
||||
boolean flag2 = wallheight3 == WallHeight.NONE;
|
||||
boolean flag3 = wallheight2 == WallHeight.NONE;
|
||||
boolean flag4 = wallheight == WallHeight.NONE;
|
||||
boolean flag5 = flag4 && flag1 && flag2 && flag3 || flag4 != flag1 || flag2 != flag3;
|
||||
if (flag5) {
|
||||
return true;
|
||||
} else {
|
||||
boolean flag6 = wallheight == WallHeight.TALL && wallheight1 == WallHeight.TALL
|
||||
|| wallheight2 == WallHeight.TALL && wallheight3 == WallHeight.TALL;
|
||||
if (flag6) {
|
||||
return false;
|
||||
} else {
|
||||
return p_235628_2_.getBlock().isIn(BlockTags.WALL_POST_OVERRIDE) || compareShapes(shape, CENTER_POLE_SHAPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasHeightForProperty(BlockState state, Property<WallHeight> heightProperty) {
|
||||
return state.get(heightProperty) != WallHeight.NONE;
|
||||
}
|
||||
|
||||
private static boolean compareShapes(VoxelShape shape1, VoxelShape shape2) {
|
||||
return !VoxelShapes.compare(shape2, shape1, IBooleanFunction.ONLY_FIRST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafDeadLogBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_dead_log")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafDeadLogBlock(HemModElements instance) {
|
||||
super(instance, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.5f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.AXE).speedFactor(0.8f).notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(AXIS, Direction.Axis.Y));
|
||||
setRegistryName("blueleaf_dead_log");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(AXIS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(AXIS, context.getFace().getAxis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
if (rot == Rotation.CLOCKWISE_90 || rot == Rotation.COUNTERCLOCKWISE_90) {
|
||||
if ((Direction.Axis) state.get(AXIS) == Direction.Axis.X) {
|
||||
return state.with(AXIS, Direction.Axis.Z);
|
||||
} else if ((Direction.Axis) state.get(AXIS) == Direction.Axis.Z) {
|
||||
return state.with(AXIS, Direction.Axis.X);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.gen.feature.template.RuleTest;
|
||||
import net.minecraft.world.gen.feature.template.IRuleTestType;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.OreFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafDirtBlockBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_dirt_block")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafDirtBlockBlock(HemModElements instance) {
|
||||
super(instance, 2);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.EARTH).sound(SoundType.GROUND).hardnessAndResistance(0.5f, 3f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.SHOVEL));
|
||||
setRegistryName("blueleaf_dirt_block");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private static Feature<OreFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
private static IRuleTestType<CustomRuleTest> CUSTOM_MATCH = null;
|
||||
|
||||
private static class CustomRuleTest extends RuleTest {
|
||||
static final CustomRuleTest INSTANCE = new CustomRuleTest();
|
||||
static final com.mojang.serialization.Codec<CustomRuleTest> codec = com.mojang.serialization.Codec.unit(() -> INSTANCE);
|
||||
|
||||
public boolean test(BlockState blockAt, Random random) {
|
||||
boolean blockCriteria = false;
|
||||
if (blockAt.getBlock() == BlueleafGravelMudBlock.block)
|
||||
blockCriteria = true;
|
||||
if (blockAt.getBlock() == BlueleafMudBlock.block)
|
||||
blockCriteria = true;
|
||||
if (blockAt.getBlock() == BlueleafStoneGravelBlock.block)
|
||||
blockCriteria = true;
|
||||
return blockCriteria;
|
||||
}
|
||||
|
||||
protected IRuleTestType<?> getType() {
|
||||
return CUSTOM_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
CUSTOM_MATCH = Registry.register(Registry.RULE_TEST, new ResourceLocation("hem:blueleaf_dirt_block_match"), () -> CustomRuleTest.codec);
|
||||
feature = new OreFeature(OreFeatureConfig.CODEC) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random rand, BlockPos pos, OreFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, rand, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(new OreFeatureConfig(CustomRuleTest.INSTANCE, block.getDefaultState(), 31)).range(256)
|
||||
.square().func_242731_b(31);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_dirt_block"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_dirt_block"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).add(() -> configuredFeature);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafDirtGrassBlockBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_dirt_grass_block")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafDirtGrassBlockBlock(HemModElements instance) {
|
||||
super(instance, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ORGANIC).sound(SoundType.PLANT).hardnessAndResistance(0.5f, 3f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.SHOVEL));
|
||||
setRegistryName("blueleaf_dirt_grass_block");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(BlueleafDirtBlockBlock.block));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.BlueleafFluorescentLeavesParticleSpawningConditionProcedure;
|
||||
import studio.halbear.hem.particle.FluorescentLeavesParticlesParticle;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafFluorescentLeavesBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_fluorescent_leaves")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafFluorescentLeavesBlock(HemModElements instance) {
|
||||
super(instance, 19);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block implements IWaterLoggable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(0.3f, 1f).setLightLevel(s -> 7)
|
||||
.harvestLevel(1).harvestTool(ToolType.HOE).slipperiness(0.7999999999999999f).speedFactor(0.6f).jumpFactor(0.6f).notSolid()
|
||||
.setNeedsPostProcessing((bs, br, bp) -> true).setEmmisiveRendering((bs, br, bp) -> true).setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
|
||||
setRegistryName("blueleaf_fluorescent_leaves");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean flag = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER;
|
||||
return this.getDefaultState().with(WATERLOGGED, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(Blocks.CAVE_AIR));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (BlueleafFluorescentLeavesParticleSpawningConditionProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("world", world))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll)))
|
||||
for (int l = 0; l < 1; ++l) {
|
||||
double d0 = (x + random.nextFloat());
|
||||
double d1 = (y + random.nextFloat());
|
||||
double d2 = (z + random.nextFloat());
|
||||
int i1 = random.nextInt(2) * 2 - 1;
|
||||
double d3 = (random.nextFloat() - 0.5D) * 1D;
|
||||
double d4 = (random.nextFloat() - 0.5D) * 1D;
|
||||
double d5 = (random.nextFloat() - 0.5D) * 1D;
|
||||
world.addParticle(FluorescentLeavesParticlesParticle.particle, d0, d1, d2, d3, d4, d5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.placement.Placement;
|
||||
import net.minecraft.world.gen.placement.NoiseDependant;
|
||||
import net.minecraft.world.gen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafGrassBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_grass")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafGrassBlock(HemModElements instance) {
|
||||
super(instance, 19);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new RandomPatchFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer())).tries(32)
|
||||
.build())
|
||||
.withPlacement(Placement.COUNT_NOISE.configure(new NoiseDependant(-0.8, 0, 40)));
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_grass"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_grass"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.HASTE, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_grass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 16, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
|
||||
return useContext.getItem().getItem() != this.asItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.util.ForgeSoundType;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafGrassBlockBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_grass_block")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafGrassBlockBlock(HemModElements instance) {
|
||||
super(instance, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ORGANIC)
|
||||
.sound(new ForgeSoundType(1.0f, 1.0f, () -> new SoundEvent(new ResourceLocation("block.stone.break")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.grass.step")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.stone.place")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.stone.hit")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.grass.fall"))))
|
||||
.hardnessAndResistance(1f, 10f).setLightLevel(s -> 0).harvestLevel(1).harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_grass_block");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(BlueleafStoneBlock.block));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.util.ForgeSoundType;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafGravelMudBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_gravel_mud")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafGravelMudBlock(HemModElements instance) {
|
||||
super(instance, 129);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends FallingBlock {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.EARTH)
|
||||
.sound(new ForgeSoundType(1.0f, 1.0f, () -> new SoundEvent(new ResourceLocation("block.soul_soil.break")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.gravel.step")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.soul_soil.place")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.soul_soil.hit")),
|
||||
() -> new SoundEvent(new ResourceLocation("block.gravel.fall"))))
|
||||
.hardnessAndResistance(0.35f, 3.5f).setLightLevel(s -> 0).harvestLevel(1).harvestTool(ToolType.SHOVEL)
|
||||
.slipperiness(0.7999999999999999f));
|
||||
setRegistryName("blueleaf_gravel_mud");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafGreenCapBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_green_cap")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafGreenCapBlock(HemModElements instance) {
|
||||
super(instance, 47);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(16).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(5);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_green_cap"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_green_cap"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.RESISTANCE, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_green_cap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.BlueleafLavenderUpdateTickProcedure;
|
||||
import studio.halbear.hem.procedures.BlueleafLavenderMobplayerCollidesWithPlantProcedure;
|
||||
import studio.halbear.hem.procedures.BlueleafLavenderConditionProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.gen.placement.Placement;
|
||||
import net.minecraft.world.gen.placement.NoiseDependant;
|
||||
import net.minecraft.world.gen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafLavenderBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_lavender")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafLavenderBlock(HemModElements instance) {
|
||||
super(instance, 41);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new RandomPatchFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (!BlueleafLavenderConditionProcedure
|
||||
.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll)))
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer())).tries(256)
|
||||
.build())
|
||||
.withPlacement(Placement.COUNT_NOISE.configure(new NoiseDependant(-0.8, 0, 40)));
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_lavender"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_lavender"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_hayfever_fields").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.REGENERATION, 100, Block.Properties.create(Material.PLANTS).tickRandomly().doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_lavender");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 32, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockstate, ServerWorld world, BlockPos pos, Random random) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
BlueleafLavenderUpdateTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
BlueleafLavenderMobplayerCollidesWithPlantProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafLeavesBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_leaves")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafLeavesBlock(HemModElements instance) {
|
||||
super(instance, 120);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block implements IWaterLoggable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(0.3f, 1f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.HOE).slipperiness(0.7000000000000001f).speedFactor(0.7000000000000001f).jumpFactor(0.9f)
|
||||
.notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
|
||||
setRegistryName("blueleaf_leaves");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean flag = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER;
|
||||
return this.getDefaultState().with(WATERLOGGED, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(Blocks.CAVE_AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.GiantLilyPadEntityCollidesInTheBlockProcedure;
|
||||
import studio.halbear.hem.particle.LilyPadParticlesParticle;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafLilyPadBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_lily_pad")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafLilyPadBlock(HemModElements instance) {
|
||||
super(instance, 157);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.PLANTS).sound(SoundType.LILY_PADS).hardnessAndResistance(0.1f, 0f).setLightLevel(s -> 1)
|
||||
.harvestLevel(1).harvestTool(ToolType.HOE).slipperiness(1f).jumpFactor(1.5f).notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
|
||||
setRegistryName("blueleaf_lily_pad");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
return state.with(FACING, rot.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (true)
|
||||
for (int l = 0; l < 1; ++l) {
|
||||
double d0 = (double) ((float) x + 0.5) + (double) (random.nextFloat() - 0.5) * 0.4D;
|
||||
double d1 = ((double) ((float) y + 0.7) + (double) (random.nextFloat() - 0.5) * 0.4D) + 0.5;
|
||||
double d2 = (double) ((float) z + 0.5) + (double) (random.nextFloat() - 0.5) * 0.4D;
|
||||
world.addParticle(LilyPadParticlesParticle.particle, d0, d1, d2, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
GiantLilyPadEntityCollidesInTheBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafLogBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_log")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafLogBlock(HemModElements instance) {
|
||||
super(instance, 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.5f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.AXE));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(AXIS, Direction.Axis.Y));
|
||||
setRegistryName("blueleaf_log");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(AXIS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(AXIS, context.getFace().getAxis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
if (rot == Rotation.CLOCKWISE_90 || rot == Rotation.COUNTERCLOCKWISE_90) {
|
||||
if ((Direction.Axis) state.get(AXIS) == Direction.Axis.X) {
|
||||
return state.with(AXIS, Direction.Axis.Z);
|
||||
} else if ((Direction.Axis) state.get(AXIS) == Direction.Axis.Z) {
|
||||
return state.with(AXIS, Direction.Axis.X);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafLushLeavesBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_lush_leaves")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafLushLeavesBlock(HemModElements instance) {
|
||||
super(instance, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block implements IWaterLoggable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(0.3f, 1f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.HOE).slipperiness(0.7000000000000001f).speedFactor(0.7000000000000001f).jumpFactor(0.9f)
|
||||
.notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
|
||||
setRegistryName("blueleaf_lush_leaves");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean flag = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER;
|
||||
return this.getDefaultState().with(WATERLOGGED, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(Blocks.CAVE_AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafMatureBlossomerBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_mature_blossomer")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafMatureBlossomerBlock(HemModElements instance) {
|
||||
super(instance, 29);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(64).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(3);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_mature_blossomer"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_mature_blossomer"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.JUMP_BOOST, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_mature_blossomer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafMatureCabbageFlowerBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_mature_cabbage_flower")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafMatureCabbageFlowerBlock(HemModElements instance) {
|
||||
super(instance, 48);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(64).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(5);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_mature_cabbage_flower"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_mature_cabbage_flower"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.WATER_BREATHING, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_mature_cabbage_flower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.gen.feature.template.RuleTest;
|
||||
import net.minecraft.world.gen.feature.template.IRuleTestType;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.OreFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafMudBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_mud")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafMudBlock(HemModElements instance) {
|
||||
super(instance, 130);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends FallingBlock {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.EARTH).sound(SoundType.SOUL_SOIL).hardnessAndResistance(0.35f, 3.5f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.SHOVEL).slipperiness(0.7999999999999999f));
|
||||
setRegistryName("blueleaf_mud");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private static Feature<OreFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
private static IRuleTestType<CustomRuleTest> CUSTOM_MATCH = null;
|
||||
|
||||
private static class CustomRuleTest extends RuleTest {
|
||||
static final CustomRuleTest INSTANCE = new CustomRuleTest();
|
||||
static final com.mojang.serialization.Codec<CustomRuleTest> codec = com.mojang.serialization.Codec.unit(() -> INSTANCE);
|
||||
|
||||
public boolean test(BlockState blockAt, Random random) {
|
||||
boolean blockCriteria = false;
|
||||
if (blockAt.getBlock() == BlueleafGravelMudBlock.block)
|
||||
blockCriteria = true;
|
||||
if (blockAt.getBlock() == BlueleafStoneGravelBlock.block)
|
||||
blockCriteria = true;
|
||||
if (blockAt.getBlock() == BlueleafMudBlock.block)
|
||||
blockCriteria = true;
|
||||
return blockCriteria;
|
||||
}
|
||||
|
||||
protected IRuleTestType<?> getType() {
|
||||
return CUSTOM_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
CUSTOM_MATCH = Registry.register(Registry.RULE_TEST, new ResourceLocation("hem:blueleaf_mud_match"), () -> CustomRuleTest.codec);
|
||||
feature = new OreFeature(OreFeatureConfig.CODEC) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random rand, BlockPos pos, OreFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, rand, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(new OreFeatureConfig(CustomRuleTest.INSTANCE, block.getDefaultState(), 31)).range(256)
|
||||
.square().func_242731_b(31);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_mud"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_mud"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).add(() -> configuredFeature);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafRedCapBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_red_cap")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafRedCapBlock(HemModElements instance) {
|
||||
super(instance, 32);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(16).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(5);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_red_cap"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_red_cap"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.INSTANT_DAMAGE, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_red_cap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafRedwoodLeavesBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_redwood_leaves")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafRedwoodLeavesBlock(HemModElements instance) {
|
||||
super(instance, 21);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block implements IWaterLoggable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(0.3f, 1f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.HOE).slipperiness(0.7000000000000001f).speedFactor(0.7999999999999999f).notSolid()
|
||||
.setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
|
||||
setRegistryName("blueleaf_redwood_leaves");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean flag = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER;
|
||||
return this.getDefaultState().with(WATERLOGGED, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(Blocks.CAVE_AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafRedwoodLogBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_redwood_log")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafRedwoodLogBlock(HemModElements instance) {
|
||||
super(instance, 18);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.5f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.AXE));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(AXIS, Direction.Axis.Y));
|
||||
setRegistryName("blueleaf_redwood_log");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(AXIS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(AXIS, context.getFace().getAxis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
if (rot == Rotation.CLOCKWISE_90 || rot == Rotation.COUNTERCLOCKWISE_90) {
|
||||
if ((Direction.Axis) state.get(AXIS) == Direction.Axis.X) {
|
||||
return state.with(AXIS, Direction.Axis.Z);
|
||||
} else if ((Direction.Axis) state.get(AXIS) == Direction.Axis.Z) {
|
||||
return state.with(AXIS, Direction.Axis.X);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafSeaGrassBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_sea_grass")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafSeaGrassBlock(HemModElements instance) {
|
||||
super(instance, 52);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block implements IWaterLoggable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(0.1f, 0f).setLightLevel(s -> 1)
|
||||
.doesNotBlockMovement().notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
|
||||
setRegistryName("blueleaf_sea_grass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean flag = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER;
|
||||
return this.getDefaultState().with(WATERLOGGED, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext context) {
|
||||
return context.getItem().getItem() != this.asItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block.OffsetType getOffsetType() {
|
||||
return Block.OffsetType.XZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (true)
|
||||
for (int l = 0; l < 1; ++l) {
|
||||
double d0 = (x + random.nextFloat());
|
||||
double d1 = (y + random.nextFloat());
|
||||
double d2 = (z + random.nextFloat());
|
||||
int i1 = random.nextInt(2) * 2 - 1;
|
||||
double d3 = (random.nextFloat() - 0.5D) * 0.5D;
|
||||
double d4 = (random.nextFloat() - 0.5D) * 0.5D;
|
||||
double d5 = (random.nextFloat() - 0.5D) * 0.5D;
|
||||
world.addParticle(ParticleTypes.BUBBLE, d0, d1, d2, d3, d4, d5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafStoneBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_stone")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafStoneBlock(HemModElements instance) {
|
||||
super(instance, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_stone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(BlueleafCobblestoneBlock.block));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.world.gen.feature.template.RuleTest;
|
||||
import net.minecraft.world.gen.feature.template.IRuleTestType;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.OreFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafStoneGravelBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_stone_gravel")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafStoneGravelBlock(HemModElements instance) {
|
||||
super(instance, 14);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends FallingBlock {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.GROUND).hardnessAndResistance(0.35f, 3.5f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.SHOVEL).slipperiness(0.7999999999999999f));
|
||||
setRegistryName("blueleaf_stone_gravel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private static Feature<OreFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
private static IRuleTestType<CustomRuleTest> CUSTOM_MATCH = null;
|
||||
|
||||
private static class CustomRuleTest extends RuleTest {
|
||||
static final CustomRuleTest INSTANCE = new CustomRuleTest();
|
||||
static final com.mojang.serialization.Codec<CustomRuleTest> codec = com.mojang.serialization.Codec.unit(() -> INSTANCE);
|
||||
|
||||
public boolean test(BlockState blockAt, Random random) {
|
||||
boolean blockCriteria = false;
|
||||
if (blockAt.getBlock() == BlueleafStoneBlock.block)
|
||||
blockCriteria = true;
|
||||
return blockCriteria;
|
||||
}
|
||||
|
||||
protected IRuleTestType<?> getType() {
|
||||
return CUSTOM_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
CUSTOM_MATCH = Registry.register(Registry.RULE_TEST, new ResourceLocation("hem:blueleaf_stone_gravel_match"), () -> CustomRuleTest.codec);
|
||||
feature = new OreFeature(OreFeatureConfig.CODEC) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random rand, BlockPos pos, OreFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, rand, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(new OreFeatureConfig(CustomRuleTest.INSTANCE, block.getDefaultState(), 30)).range(256)
|
||||
.square().func_242731_b(30);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_stone_gravel"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_stone_gravel"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES).add(() -> configuredFeature);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import net.minecraft.state.properties.SlabType;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafStoneSlabBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_stone_slab")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafStoneSlabBlock(HemModElements instance) {
|
||||
super(instance, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends SlabBlock {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_stone_slab");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, state.get(TYPE) == SlabType.DOUBLE ? 2 : 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafStoneStairBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_stone_stair")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafStoneStairBlock(HemModElements instance) {
|
||||
super(instance, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends StairsBlock {
|
||||
public CustomBlock() {
|
||||
super(() -> new Block(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0)
|
||||
.harvestLevel(1).harvestTool(ToolType.PICKAXE).setRequiresTool()).getDefaultState(),
|
||||
Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_stone_stair");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.state.Property;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.WallHeight;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafStoneWallBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_stone_wall")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafStoneWallBlock(HemModElements instance) {
|
||||
super(instance, 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends WallBlock {
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.PICKAXE).setRequiresTool());
|
||||
setRegistryName("blueleaf_stone_wall");
|
||||
}
|
||||
|
||||
private static final VoxelShape CENTER_POLE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_NORTH_SIDE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 0.0D, 9.0D, 16.0D, 9.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_SOUTH_SIDE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 7.0D, 9.0D, 16.0D, 16.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_WEST_SIDE_SHAPE = Block.makeCuboidShape(0.0D, 0.0D, 7.0D, 9.0D, 16.0D, 9.0D);
|
||||
private static final VoxelShape WALL_CONNECTION_EAST_SIDE_SHAPE = Block.makeCuboidShape(7.0D, 0.0D, 7.0D, 16.0D, 16.0D, 9.0D);
|
||||
|
||||
private boolean shouldConnect(BlockState state, boolean checkattach, Direction face) {
|
||||
boolean flag = state.getBlock() instanceof WallBlock
|
||||
|| state.getBlock() instanceof FenceGateBlock && FenceGateBlock.isParallel(state, face);
|
||||
return !cannotAttach(state.getBlock()) && checkattach || flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
IWorldReader iworldreader = context.getWorld();
|
||||
BlockPos blockpos = context.getPos();
|
||||
FluidState fluidstate = context.getWorld().getFluidState(context.getPos());
|
||||
BlockPos blockpos1 = blockpos.north();
|
||||
BlockPos blockpos2 = blockpos.east();
|
||||
BlockPos blockpos3 = blockpos.south();
|
||||
BlockPos blockpos4 = blockpos.west();
|
||||
BlockPos blockpos5 = blockpos.up();
|
||||
BlockState blockstate = iworldreader.getBlockState(blockpos1);
|
||||
BlockState blockstate1 = iworldreader.getBlockState(blockpos2);
|
||||
BlockState blockstate2 = iworldreader.getBlockState(blockpos3);
|
||||
BlockState blockstate3 = iworldreader.getBlockState(blockpos4);
|
||||
BlockState blockstate4 = iworldreader.getBlockState(blockpos5);
|
||||
boolean flag = this.shouldConnect(blockstate, blockstate.isSolidSide(iworldreader, blockpos1, Direction.SOUTH), Direction.SOUTH);
|
||||
boolean flag1 = this.shouldConnect(blockstate1, blockstate1.isSolidSide(iworldreader, blockpos2, Direction.WEST), Direction.WEST);
|
||||
boolean flag2 = this.shouldConnect(blockstate2, blockstate2.isSolidSide(iworldreader, blockpos3, Direction.NORTH), Direction.NORTH);
|
||||
boolean flag3 = this.shouldConnect(blockstate3, blockstate3.isSolidSide(iworldreader, blockpos4, Direction.EAST), Direction.EAST);
|
||||
BlockState blockstate5 = this.getDefaultState().with(WATERLOGGED, Boolean.valueOf(fluidstate.getFluid() == Fluids.WATER));
|
||||
return this.func_235626_a_(iworldreader, blockstate5, blockpos5, blockstate4, flag, flag1, flag2, flag3);
|
||||
}
|
||||
|
||||
@Override /**
|
||||
* Update the provided state given the provided neighbor facing and neighbor state, returning a new state. For example, fences make their connections to the passed in state if possible, and wet concrete powder immediately returns its solidified counterpart. Note that this method should ideally consider only the specific face passed in.
|
||||
*/
|
||||
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (stateIn.get(WATERLOGGED)) {
|
||||
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
|
||||
}
|
||||
if (facing == Direction.DOWN) {
|
||||
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
|
||||
} else {
|
||||
return facing == Direction.UP
|
||||
? this.func_235625_a_(worldIn, stateIn, facingPos, facingState)
|
||||
: this.func_235627_a_(worldIn, currentPos, stateIn, facingPos, facingState, facing);
|
||||
}
|
||||
}
|
||||
|
||||
private BlockState func_235625_a_(IWorldReader reader, BlockState state1, BlockPos pos, BlockState state2) {
|
||||
boolean flag = hasHeightForProperty(state1, WALL_HEIGHT_NORTH);
|
||||
boolean flag1 = hasHeightForProperty(state1, WALL_HEIGHT_EAST);
|
||||
boolean flag2 = hasHeightForProperty(state1, WALL_HEIGHT_SOUTH);
|
||||
boolean flag3 = hasHeightForProperty(state1, WALL_HEIGHT_WEST);
|
||||
return this.func_235626_a_(reader, state1, pos, state2, flag, flag1, flag2, flag3);
|
||||
}
|
||||
|
||||
private BlockState func_235627_a_(IWorldReader reader, BlockPos p_235627_2_, BlockState p_235627_3_, BlockPos p_235627_4_,
|
||||
BlockState p_235627_5_, Direction directionIn) {
|
||||
Direction direction = directionIn.getOpposite();
|
||||
boolean flag = directionIn == Direction.NORTH
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_NORTH);
|
||||
boolean flag1 = directionIn == Direction.EAST
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_EAST);
|
||||
boolean flag2 = directionIn == Direction.SOUTH
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_SOUTH);
|
||||
boolean flag3 = directionIn == Direction.WEST
|
||||
? this.shouldConnect(p_235627_5_, p_235627_5_.isSolidSide(reader, p_235627_4_, direction), direction)
|
||||
: hasHeightForProperty(p_235627_3_, WALL_HEIGHT_WEST);
|
||||
BlockPos blockpos = p_235627_2_.up();
|
||||
BlockState blockstate = reader.getBlockState(blockpos);
|
||||
return this.func_235626_a_(reader, p_235627_3_, blockpos, blockstate, flag, flag1, flag2, flag3);
|
||||
}
|
||||
|
||||
private BlockState func_235626_a_(IWorldReader reader, BlockState state, BlockPos pos, BlockState collisionState, boolean connectedSouth,
|
||||
boolean connectedWest, boolean connectedNorth, boolean connectedEast) {
|
||||
VoxelShape voxelshape = collisionState.getCollisionShape(reader, pos).project(Direction.DOWN);
|
||||
BlockState blockstate = this.func_235630_a_(state, connectedSouth, connectedWest, connectedNorth, connectedEast, voxelshape);
|
||||
return blockstate.with(UP, Boolean.valueOf(this.func_235628_a_(blockstate, collisionState, voxelshape)));
|
||||
}
|
||||
|
||||
private BlockState func_235630_a_(BlockState state, boolean connectedSouth, boolean connectedWest, boolean connectedNorth,
|
||||
boolean connectedEast, VoxelShape shape) {
|
||||
return state.with(WALL_HEIGHT_NORTH, this.func_235633_a_(connectedSouth, shape, WALL_CONNECTION_NORTH_SIDE_SHAPE))
|
||||
.with(WALL_HEIGHT_EAST, this.func_235633_a_(connectedWest, shape, WALL_CONNECTION_EAST_SIDE_SHAPE))
|
||||
.with(WALL_HEIGHT_SOUTH, this.func_235633_a_(connectedNorth, shape, WALL_CONNECTION_SOUTH_SIDE_SHAPE))
|
||||
.with(WALL_HEIGHT_WEST, this.func_235633_a_(connectedEast, shape, WALL_CONNECTION_WEST_SIDE_SHAPE));
|
||||
}
|
||||
|
||||
private WallHeight func_235633_a_(boolean p_235633_1_, VoxelShape p_235633_2_, VoxelShape p_235633_3_) {
|
||||
if (p_235633_1_) {
|
||||
return compareShapes(p_235633_2_, p_235633_3_) ? WallHeight.TALL : WallHeight.LOW;
|
||||
} else {
|
||||
return WallHeight.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean func_235628_a_(BlockState p_235628_1_, BlockState p_235628_2_, VoxelShape shape) {
|
||||
boolean flag = p_235628_2_.getBlock() instanceof WallBlock && p_235628_2_.get(UP);
|
||||
if (flag) {
|
||||
return true;
|
||||
} else {
|
||||
WallHeight wallheight = p_235628_1_.get(WALL_HEIGHT_NORTH);
|
||||
WallHeight wallheight1 = p_235628_1_.get(WALL_HEIGHT_SOUTH);
|
||||
WallHeight wallheight2 = p_235628_1_.get(WALL_HEIGHT_EAST);
|
||||
WallHeight wallheight3 = p_235628_1_.get(WALL_HEIGHT_WEST);
|
||||
boolean flag1 = wallheight1 == WallHeight.NONE;
|
||||
boolean flag2 = wallheight3 == WallHeight.NONE;
|
||||
boolean flag3 = wallheight2 == WallHeight.NONE;
|
||||
boolean flag4 = wallheight == WallHeight.NONE;
|
||||
boolean flag5 = flag4 && flag1 && flag2 && flag3 || flag4 != flag1 || flag2 != flag3;
|
||||
if (flag5) {
|
||||
return true;
|
||||
} else {
|
||||
boolean flag6 = wallheight == WallHeight.TALL && wallheight1 == WallHeight.TALL
|
||||
|| wallheight2 == WallHeight.TALL && wallheight3 == WallHeight.TALL;
|
||||
if (flag6) {
|
||||
return false;
|
||||
} else {
|
||||
return p_235628_2_.getBlock().isIn(BlockTags.WALL_POST_OVERRIDE) || compareShapes(shape, CENTER_POLE_SHAPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasHeightForProperty(BlockState state, Property<WallHeight> heightProperty) {
|
||||
return state.get(heightProperty) != WallHeight.NONE;
|
||||
}
|
||||
|
||||
private static boolean compareShapes(VoxelShape shape1, VoxelShape shape2) {
|
||||
return !VoxelShapes.compare(shape2, shape1, IBooleanFunction.ONLY_FIRST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.DoublePlantBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.TallBlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.DoublePlantBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafTallBloomingFlowerBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_tall_blooming_flower")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafTallBloomingFlowerBlock(HemModElements instance) {
|
||||
super(instance, 28);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new TallBlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new RandomPatchFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new DoublePlantBlockPlacer()))
|
||||
.tries(8).func_227317_b_().build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(12);
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_tall_blooming_flower"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_tall_blooming_flower"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends DoublePlantBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT).hardnessAndResistance(0f, 0f)
|
||||
.setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_tall_blooming_flower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
if (state.get(BlockStateProperties.DOUBLE_BLOCK_HALF) != DoubleBlockHalf.LOWER)
|
||||
return Collections.emptyList();
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.placement.Placement;
|
||||
import net.minecraft.world.gen.placement.NoiseDependant;
|
||||
import net.minecraft.world.gen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.DoublePlantBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.TallBlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.DoublePlantBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafTallGrassBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_tall_grass")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafTallGrassBlock(HemModElements instance) {
|
||||
super(instance, 26);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new TallBlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new RandomPatchFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new DoublePlantBlockPlacer()))
|
||||
.tries(12).build())
|
||||
.withPlacement(Placement.COUNT_NOISE.configure(new NoiseDependant(-0.8, 0, 15)));
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_tall_grass"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_tall_grass"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends DoublePlantBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT).hardnessAndResistance(0f, 0f)
|
||||
.setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_tall_grass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
|
||||
return useContext.getItem().getItem() != this.asItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
if (state.get(BlockStateProperties.DOUBLE_BLOCK_HALF) != DoubleBlockHalf.LOWER)
|
||||
return Collections.emptyList();
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.placement.Placement;
|
||||
import net.minecraft.world.gen.placement.NoiseDependant;
|
||||
import net.minecraft.world.gen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.DoublePlantBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.TallBlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.DoublePlantBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafTallSproutBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_tall_sprout")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafTallSproutBlock(HemModElements instance) {
|
||||
super(instance, 27);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new TallBlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new RandomPatchFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new DoublePlantBlockPlacer()))
|
||||
.tries(12).build())
|
||||
.withPlacement(Placement.COUNT_NOISE.configure(new NoiseDependant(-0.8, 0, 15)));
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_tall_sprout"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_tall_sprout"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends DoublePlantBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT).hardnessAndResistance(0f, 0f)
|
||||
.setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_tall_sprout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
if (state.get(BlockStateProperties.DOUBLE_BLOCK_HALF) != DoubleBlockHalf.LOWER)
|
||||
return Collections.emptyList();
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.BlueleafWheatAdditionalGenerationConditionProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.gen.placement.Placement;
|
||||
import net.minecraft.world.gen.placement.NoiseDependant;
|
||||
import net.minecraft.world.gen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafWheatBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_wheat")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafWheatBlock(HemModElements instance) {
|
||||
super(instance, 42);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new RandomPatchFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (!BlueleafWheatAdditionalGenerationConditionProcedure
|
||||
.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll)))
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer())).tries(256)
|
||||
.build())
|
||||
.withPlacement(Placement.COUNT_NOISE.configure(new NoiseDependant(-0.8, 0, 40)));
|
||||
event.getRegistry().register(feature.setRegistryName("blueleaf_wheat"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:blueleaf_wheat"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_hayfever_fields").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.REGENERATION, 100, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("blueleaf_wheat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 32, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafWoodBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:blueleaf_wood")
|
||||
public static final Block block = null;
|
||||
|
||||
public BlueleafWoodBlock(HemModElements instance) {
|
||||
super(instance, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(0.5f, 10f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.AXE));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(AXIS, Direction.Axis.Y));
|
||||
setRegistryName("blueleaf_wood");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(AXIS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(AXIS, context.getFace().getAxis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
if (rot == Rotation.CLOCKWISE_90 || rot == Rotation.COUNTERCLOCKWISE_90) {
|
||||
if ((Direction.Axis) state.get(AXIS) == Direction.Axis.X) {
|
||||
return state.with(AXIS, Direction.Axis.Z);
|
||||
} else if ((Direction.Axis) state.get(AXIS) == Direction.Axis.Z) {
|
||||
return state.with(AXIS, Direction.Axis.X);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction direction, IPlantable plantable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(BlueleafLogBlock.block));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.BulbFlowerUpdateTickProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BulbFlowerBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:bulb_flower")
|
||||
public static final Block block = null;
|
||||
|
||||
public BulbFlowerBlock(HemModElements instance) {
|
||||
super(instance, 40);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(7).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(15);
|
||||
event.getRegistry().register(feature.setRegistryName("bulb_flower"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:bulb_flower"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.HASTE, 100, Block.Properties.create(Material.PLANTS).tickRandomly().doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).speedFactor(0.5f).setLightLevel(s -> 1));
|
||||
setRegistryName("bulb_flower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 32, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockstate, ServerWorld world, BlockPos pos, Random random) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
BulbFlowerUpdateTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState blockstate, World world, BlockPos pos, PlayerEntity entity, Hand hand,
|
||||
BlockRayTraceResult hit) {
|
||||
super.onBlockActivated(blockstate, world, pos, entity, hand, hit);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
double hitX = hit.getHitVec().x;
|
||||
double hitY = hit.getHitVec().y;
|
||||
double hitZ = hit.getHitVec().z;
|
||||
Direction direction = hit.getFace();
|
||||
|
||||
BulbFlowerUpdateTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.DanglingFluorescentLeavesNeighbourBlockChangesProcedure;
|
||||
import studio.halbear.hem.procedures.DanglingFluorescentLeavesBlockValidPlacementConditionProcedure;
|
||||
import studio.halbear.hem.particle.FluorescentLeavesParticlesParticle;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class DanglingFluorescentLeavesBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:dangling_fluorescent_leaves")
|
||||
public static final Block block = null;
|
||||
|
||||
public DanglingFluorescentLeavesBlock(HemModElements instance) {
|
||||
super(instance, 23);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block implements IWaterLoggable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).sound(SoundType.GROUND).hardnessAndResistance(1f, 10f).setLightLevel(s -> 10)
|
||||
.doesNotBlockMovement().notSolid().tickRandomly().setNeedsPostProcessing((bs, br, bp) -> true)
|
||||
.setEmmisiveRendering((bs, br, bp) -> true).setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
|
||||
setRegistryName("dangling_fluorescent_leaves");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(2, 0, 2, 14, 16, 14))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean flag = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER;
|
||||
return this.getDefaultState().with(WATERLOGGED, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState blockstate, IWorldReader worldIn, BlockPos pos) {
|
||||
if (worldIn instanceof IWorld) {
|
||||
IWorld world = (IWorld) worldIn;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
return DanglingFluorescentLeavesBlockValidPlacementConditionProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x),
|
||||
new AbstractMap.SimpleEntry<>("y", y), new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
return super.isValidPosition(blockstate, worldIn, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return !state.isValidPosition(world, currentPos)
|
||||
? Blocks.AIR.getDefaultState()
|
||||
: super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState blockstate, World world, BlockPos pos, Block neighborBlock, BlockPos fromPos, boolean moving) {
|
||||
super.neighborChanged(blockstate, world, pos, neighborBlock, fromPos, moving);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (world.getRedstonePowerFromNeighbors(new BlockPos(x, y, z)) > 0) {
|
||||
} else {
|
||||
}
|
||||
|
||||
DanglingFluorescentLeavesNeighbourBlockChangesProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (true)
|
||||
for (int l = 0; l < 1; ++l) {
|
||||
double d0 = (x + random.nextFloat());
|
||||
double d1 = (y + random.nextFloat());
|
||||
double d2 = (z + random.nextFloat());
|
||||
int i1 = random.nextInt(2) * 2 - 1;
|
||||
double d3 = (random.nextFloat() - 0.5D) * 0.5D;
|
||||
double d4 = (random.nextFloat() - 0.5D) * 0.5D;
|
||||
double d5 = (random.nextFloat() - 0.5D) * 0.5D;
|
||||
world.addParticle(FluorescentLeavesParticlesParticle.particle, d0, d1, d2, d3, d4, d5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.FallenLeavesEntityCollidesInTheBlockProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class FallenLeavesBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:fallen_leaves")
|
||||
public static final Block block = null;
|
||||
|
||||
public FallenLeavesBlock(HemModElements instance) {
|
||||
super(instance, 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block implements IWaterLoggable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(1f, 10f).setLightLevel(s -> 0)
|
||||
.doesNotBlockMovement().slipperiness(0.7999999999999999f).notSolid().tickRandomly().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
|
||||
setRegistryName("fallen_leaves");
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) {
|
||||
return adjacentBlockState.getBlock() == this ? true : super.isSideInvisible(state, adjacentBlockState, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 1, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
boolean flag = context.getWorld().getFluidState(context.getPos()).getFluid() == Fluids.WATER;
|
||||
return this.getDefaultState().with(WATERLOGGED, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos currentPos,
|
||||
BlockPos facingPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(BlockState state, BlockItemUseContext context) {
|
||||
return context.getItem().getItem() != this.asItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
FallenLeavesEntityCollidesInTheBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.GiantLilyPadEntityCollidesInTheBlockProcedure;
|
||||
import studio.halbear.hem.particle.LilyPadParticlesParticle;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class GiantLilyPadBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:giant_lily_pad")
|
||||
public static final Block block = null;
|
||||
|
||||
public GiantLilyPadBlock(HemModElements instance) {
|
||||
super(instance, 38);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.PLANTS).sound(SoundType.LILY_PADS).hardnessAndResistance(0.1f, 0f).setLightLevel(s -> 1)
|
||||
.harvestLevel(1).harvestTool(ToolType.HOE).slipperiness(1f).jumpFactor(1.5f).notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
|
||||
setRegistryName("giant_lily_pad");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
switch ((Direction) state.get(FACING)) {
|
||||
case SOUTH :
|
||||
default :
|
||||
return VoxelShapes.or(makeCuboidShape(22, 0, 22, -6, 1, -6))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case NORTH :
|
||||
return VoxelShapes.or(makeCuboidShape(-6, 0, -6, 22, 1, 22))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case EAST :
|
||||
return VoxelShapes.or(makeCuboidShape(22, 0, -6, -6, 1, 22))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case WEST :
|
||||
return VoxelShapes.or(makeCuboidShape(-6, 0, 22, 22, 1, -6))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
return state.with(FACING, rot.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (true)
|
||||
for (int l = 0; l < 1; ++l) {
|
||||
double d0 = (double) ((float) x + 0.5) + (double) (random.nextFloat() - 0.5) * 0.4D;
|
||||
double d1 = ((double) ((float) y + 0.7) + (double) (random.nextFloat() - 0.5) * 0.4D) + 0.5;
|
||||
double d2 = (double) ((float) z + 0.5) + (double) (random.nextFloat() - 0.5) * 0.4D;
|
||||
world.addParticle(LilyPadParticlesParticle.particle, d0, d1, d2, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
GiantLilyPadEntityCollidesInTheBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.MuncherUpdateTickProcedure;
|
||||
import studio.halbear.hem.procedures.MuncherPlantAddedProcedure;
|
||||
import studio.halbear.hem.procedures.MuncherBlockDestroyedByPlayerProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.LockableLootTileEntity;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ChestContainer;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class MuncherBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:muncher")
|
||||
public static final Block block = null;
|
||||
@ObjectHolder("hem:muncher")
|
||||
public static final TileEntityType<CustomTileEntity> tileEntityType = null;
|
||||
|
||||
public MuncherBlock(HemModElements instance) {
|
||||
super(instance, 33);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new TileEntityRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new CustomBlock());
|
||||
elements.items
|
||||
.add(() -> new BlockItem(block, new Item.Properties().group(BlueleafTabItemGroup.tab)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
private static class TileEntityRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerTileEntity(RegistryEvent.Register<TileEntityType<?>> event) {
|
||||
event.getRegistry().register(TileEntityType.Builder.create(CustomTileEntity::new, block).build(null).setRegistryName("muncher"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutoutMipped());
|
||||
}
|
||||
|
||||
public static class CustomBlock extends Block {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public CustomBlock() {
|
||||
super(Block.Properties.create(Material.PLANTS).sound(SoundType.PLANT).hardnessAndResistance(1f, 1f).setLightLevel(s -> 0).harvestLevel(1)
|
||||
.harvestTool(ToolType.HOE).doesNotBlockMovement().notSolid().setOpaque((bs, br, bp) -> false));
|
||||
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
|
||||
setRegistryName("muncher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
switch ((Direction) state.get(FACING)) {
|
||||
case SOUTH :
|
||||
default :
|
||||
return VoxelShapes.or(makeCuboidShape(16, 0, 16, 0, 32, 0))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case NORTH :
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 32, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case EAST :
|
||||
return VoxelShapes.or(makeCuboidShape(16, 0, 0, 0, 32, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
case WEST :
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 16, 16, 32, 0))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
return state.with(FACING, rot.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(this, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(BlockState blockstate, World world, BlockPos pos, BlockState oldState, boolean moving) {
|
||||
super.onBlockAdded(blockstate, world, pos, oldState, moving);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
world.getPendingBlockTicks().scheduleTick(pos, this, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockstate, ServerWorld world, BlockPos pos, Random random) {
|
||||
super.tick(blockstate, world, pos, random);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
MuncherUpdateTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
world.getPendingBlockTicks().scheduleTick(pos, this, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(BlockState blockstate, World world, BlockPos pos, PlayerEntity entity, boolean willHarvest, FluidState fluid) {
|
||||
boolean retval = super.removedByPlayer(blockstate, world, pos, entity, willHarvest, fluid);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
MuncherBlockDestroyedByPlayerProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState blockstate, World world, BlockPos pos, PlayerEntity entity, Hand hand,
|
||||
BlockRayTraceResult hit) {
|
||||
super.onBlockActivated(blockstate, world, pos, entity, hand, hit);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
double hitX = hit.getHitVec().x;
|
||||
double hitY = hit.getHitVec().y;
|
||||
double hitZ = hit.getHitVec().z;
|
||||
Direction direction = hit.getFace();
|
||||
|
||||
MuncherPlantAddedProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INamedContainerProvider getContainer(BlockState state, World worldIn, BlockPos pos) {
|
||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||
return tileEntity instanceof INamedContainerProvider ? (INamedContainerProvider) tileEntity : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return new CustomTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventReceived(BlockState state, World world, BlockPos pos, int eventID, int eventParam) {
|
||||
super.eventReceived(state, world, pos, eventID, eventParam);
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
if (tileentity instanceof CustomTileEntity) {
|
||||
InventoryHelper.dropInventoryItems(world, pos, (CustomTileEntity) tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
|
||||
super.onReplaced(state, world, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState blockState, World world, BlockPos pos) {
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
if (tileentity instanceof CustomTileEntity)
|
||||
return Container.calcRedstoneFromInventory((CustomTileEntity) tileentity);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTileEntity extends LockableLootTileEntity implements ISidedInventory {
|
||||
private NonNullList<ItemStack> stacks = NonNullList.<ItemStack>withSize(0, ItemStack.EMPTY);
|
||||
|
||||
protected CustomTileEntity() {
|
||||
super(tileEntityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(BlockState blockState, CompoundNBT compound) {
|
||||
super.read(blockState, compound);
|
||||
if (!this.checkLootAndRead(compound)) {
|
||||
this.stacks = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
|
||||
}
|
||||
ItemStackHelper.loadAllItems(compound, this.stacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT compound) {
|
||||
super.write(compound);
|
||||
if (!this.checkLootAndWrite(compound)) {
|
||||
ItemStackHelper.saveAllItems(compound, this.stacks);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SUpdateTileEntityPacket getUpdatePacket() {
|
||||
return new SUpdateTileEntityPacket(this.pos, 0, this.getUpdateTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT getUpdateTag() {
|
||||
return this.write(new CompoundNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
|
||||
this.read(this.getBlockState(), pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return stacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (ItemStack itemstack : this.stacks)
|
||||
if (!itemstack.isEmpty())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDefaultName() {
|
||||
return new StringTextComponent("muncher");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container createMenu(int id, PlayerInventory player) {
|
||||
return ChestContainer.createGeneric9X3(id, player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new StringTextComponent("Muncher 'Flower'");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getItems() {
|
||||
return this.stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> stacks) {
|
||||
this.stacks = stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(Direction side) {
|
||||
return IntStream.range(0, this.getSizeInventory()).toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack stack, @Nullable Direction direction) {
|
||||
return this.isItemValidForSlot(index, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private final LazyOptional<? extends IItemHandler>[] handlers = SidedInvWrapper.create(this, Direction.values());
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (!this.removed && facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
return handlers[facing.ordinal()].cast();
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
for (LazyOptional<? extends IItemHandler> handler : handlers)
|
||||
handler.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
|
||||
package studio.halbear.hem.block;
|
||||
|
||||
import studio.halbear.hem.procedures.MuncherSproutClientDisplayRandomTickProcedure;
|
||||
import studio.halbear.hem.procedures.MuncherSproutAdditionalGenerationConditionProcedure;
|
||||
import studio.halbear.hem.procedures.MuncherGenerationOnStructureInstanceGeneratedProcedure;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.common.PlantType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.DefaultFlowersFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
|
||||
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
|
||||
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ISeedReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.util.registry.WorldGenRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class MuncherSproutBlock extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:muncher_sprout")
|
||||
public static final Block block = null;
|
||||
|
||||
public MuncherSproutBlock(HemModElements instance) {
|
||||
super(instance, 105);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FeatureRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.blocks.add(() -> new BlockCustomFlower());
|
||||
elements.items.add(() -> new BlockItem(block, new Item.Properties().group(null)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientLoad(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(block, RenderType.getCutout());
|
||||
}
|
||||
|
||||
private static Feature<BlockClusterFeatureConfig> feature = null;
|
||||
private static ConfiguredFeature<?, ?> configuredFeature = null;
|
||||
|
||||
private static class FeatureRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerFeature(RegistryEvent.Register<Feature<?>> event) {
|
||||
feature = new DefaultFlowersFeature(BlockClusterFeatureConfig.field_236587_a_) {
|
||||
@Override
|
||||
public BlockState getFlowerToPlace(Random random, BlockPos bp, BlockClusterFeatureConfig fc) {
|
||||
return block.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(ISeedReader world, ChunkGenerator generator, Random random, BlockPos pos, BlockClusterFeatureConfig config) {
|
||||
RegistryKey<World> dimensionType = world.getWorld().getDimensionKey();
|
||||
boolean dimensionCriteria = false;
|
||||
if (dimensionType == RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("hem:blueleaf")))
|
||||
dimensionCriteria = true;
|
||||
if (!dimensionCriteria)
|
||||
return false;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
if (!MuncherSproutAdditionalGenerationConditionProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x),
|
||||
new AbstractMap.SimpleEntry<>("y", y), new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll)))
|
||||
return false;
|
||||
return super.generate(world, generator, random, pos, config);
|
||||
}
|
||||
};
|
||||
configuredFeature = feature
|
||||
.withConfiguration(
|
||||
(new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(block.getDefaultState()), new SimpleBlockPlacer()))
|
||||
.tries(5).build())
|
||||
.withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).func_242731_b(10);
|
||||
event.getRegistry().register(feature.setRegistryName("muncher_sprout"));
|
||||
Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation("hem:muncher_sprout"), configuredFeature);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getGeneration().getFeatures(GenerationStage.Decoration.VEGETAL_DECORATION).add(() -> configuredFeature);
|
||||
}
|
||||
|
||||
public static class BlockCustomFlower extends FlowerBlock {
|
||||
public BlockCustomFlower() {
|
||||
super(Effects.NAUSEA, 100, Block.Properties.create(Material.PLANTS).tickRandomly().doesNotBlockMovement().sound(SoundType.PLANT)
|
||||
.hardnessAndResistance(0f, 0f).setLightLevel(s -> 0));
|
||||
setRegistryName("muncher_sprout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStewEffectDuration() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) {
|
||||
Vector3d offset = state.getOffset(world, pos);
|
||||
return VoxelShapes.or(makeCuboidShape(0, 0, 0, 16, 16, 16))
|
||||
|
||||
.withOffset(offset.x, offset.y, offset.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face) {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
List<ItemStack> dropsOriginal = super.getDrops(state, builder);
|
||||
if (!dropsOriginal.isEmpty())
|
||||
return dropsOriginal;
|
||||
return Collections.singletonList(new ItemStack(MuncherBlock.block));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
|
||||
return PlantType.PLAINS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(BlockState blockstate, World world, BlockPos pos, BlockState oldState, boolean moving) {
|
||||
super.onBlockAdded(blockstate, world, pos, oldState, moving);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
MuncherGenerationOnStructureInstanceGeneratedProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockstate, ServerWorld world, BlockPos pos, Random random) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
MuncherGenerationOnStructureInstanceGeneratedProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void animateTick(BlockState blockstate, World world, BlockPos pos, Random random) {
|
||||
super.animateTick(blockstate, world, pos, random);
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
MuncherSproutClientDisplayRandomTickProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(BlockState blockstate, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(blockstate, world, pos, entity);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
MuncherGenerationOnStructureInstanceGeneratedProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.AirboatRightClickedOnEntityProcedure;
|
||||
import studio.halbear.hem.procedures.AirboatOnInitialEntitySpawnProcedure;
|
||||
import studio.halbear.hem.procedures.AirboatOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.AirboatRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IServerWorld;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.pathfinding.FlyingPathNavigator;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.ai.controller.FlyingMovementController;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.ILivingEntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class AirboatEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.MONSTER)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(5f, 9f))
|
||||
.build("airboat").setRegistryName("airboat");
|
||||
|
||||
public AirboatEntity(HemModElements instance) {
|
||||
super(instance, 292);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new AirboatRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("airboat_spawn_egg"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 100);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FLYING_SPEED, 0.3);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
enablePersistence();
|
||||
this.moveController = new FlyingMovementController(this, 10, true);
|
||||
this.navigator = new FlyingPathNavigator(this, this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDespawn(double distanceToClosestPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMountedYOffset() {
|
||||
return super.getMountedYOffset() + -7.2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLivingFall(float l, float d) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.DROWN)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILivingEntityData onInitialSpawn(IServerWorld world, DifficultyInstance difficulty, SpawnReason reason,
|
||||
@Nullable ILivingEntityData livingdata, @Nullable CompoundNBT tag) {
|
||||
ILivingEntityData retval = super.onInitialSpawn(world, difficulty, reason, livingdata, tag);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
AirboatOnInitialEntitySpawnProcedure
|
||||
.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType func_230254_b_(PlayerEntity sourceentity, Hand hand) {
|
||||
ItemStack itemstack = sourceentity.getHeldItem(hand);
|
||||
ActionResultType retval = ActionResultType.func_233537_a_(this.world.isRemote());
|
||||
super.func_230254_b_(sourceentity, hand);
|
||||
sourceentity.startRiding(this);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
AirboatRightClickedOnEntityProcedure.executeProcedure(
|
||||
Stream.of(new AbstractMap.SimpleEntry<>("entity", entity), new AbstractMap.SimpleEntry<>("sourceentity", sourceentity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
AirboatOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoGravity(boolean ignored) {
|
||||
super.setNoGravity(true);
|
||||
}
|
||||
|
||||
public void livingTick() {
|
||||
super.livingTick();
|
||||
this.setNoGravity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryBotEntityIsHurtProcedure;
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryBotEntityDiesProcedure;
|
||||
import studio.halbear.hem.procedures.DormantAgedEmberleafMilitaryBotOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.DormantAgedEmberleafMilitaryBotRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class DormantAgedEmberleafMilitaryBotEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.AMBIENT)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(128).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).immuneToFire()
|
||||
.size(1f, 3f)).build("dormant_aged_emberleaf_military_bot").setRegistryName("dormant_aged_emberleaf_military_bot");
|
||||
|
||||
public DormantAgedEmberleafMilitaryBotEntity(HemModElements instance) {
|
||||
super(instance, 58);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new DormantAgedEmberleafMilitaryBotRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC))
|
||||
.setRegistryName("dormant_aged_emberleaf_military_bot_spawn_egg"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_hayfever_fields").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getSpawns().getSpawner(EntityClassification.AMBIENT).add(new MobSpawnInfo.Spawners(entity, 3, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS,
|
||||
Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::canSpawnOn);
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 40);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 6);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 32);
|
||||
ammma = ammma.createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE, 5);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_KNOCKBACK, 1.5);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends MonsterEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 10;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.anvil.land"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.firework_rocket.large_blast"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
Entity sourceentity = source.getTrueSource();
|
||||
|
||||
EmberleafMilitaryBotEntityIsHurtProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource source) {
|
||||
super.onDeath(source);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity sourceentity = source.getTrueSource();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryBotEntityDiesProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
DormantAgedEmberleafMilitaryBotOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryBotEntityIsHurtProcedure;
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryBotEntityDiesProcedure;
|
||||
import studio.halbear.hem.procedures.DormantAgedEmberleafMilitaryBotOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.DormantEmberleafMilitaryBotRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class DormantEmberleafMilitaryBotEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.AMBIENT)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(128).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).immuneToFire()
|
||||
.size(1f, 3f)).build("dormant_emberleaf_military_bot").setRegistryName("dormant_emberleaf_military_bot");
|
||||
|
||||
public DormantEmberleafMilitaryBotEntity(HemModElements instance) {
|
||||
super(instance, 59);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new DormantEmberleafMilitaryBotRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC))
|
||||
.setRegistryName("dormant_emberleaf_military_bot_spawn_egg"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_hayfever_fields").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getSpawns().getSpawner(EntityClassification.AMBIENT).add(new MobSpawnInfo.Spawners(entity, 3, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.NO_RESTRICTIONS,
|
||||
Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MobEntity::canSpawnOn);
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 40);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 6);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 32);
|
||||
ammma = ammma.createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE, 5);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_KNOCKBACK, 1.5);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends MonsterEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 10;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.anvil.land"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.firework_rocket.large_blast"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
Entity sourceentity = source.getTrueSource();
|
||||
|
||||
EmberleafMilitaryBotEntityIsHurtProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource source) {
|
||||
super.onDeath(source);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity sourceentity = source.getTrueSource();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryBotEntityDiesProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
DormantAgedEmberleafMilitaryBotOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryBotOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryBotEntityIsHurtProcedure;
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryBotEntityDiesProcedure;
|
||||
import studio.halbear.hem.entity.renderer.EmberleafMilitaryBotRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
|
||||
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
|
||||
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
|
||||
import net.minecraft.entity.ai.goal.LookAtGoal;
|
||||
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class EmberleafMilitaryBotEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.AMBIENT)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(128).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).immuneToFire()
|
||||
.size(1f, 3f)).build("emberleaf_military_bot").setRegistryName("emberleaf_military_bot");
|
||||
|
||||
public EmberleafMilitaryBotEntity(HemModElements instance) {
|
||||
super(instance, 60);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EmberleafMilitaryBotRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC))
|
||||
.setRegistryName("emberleaf_military_bot_spawn_egg"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 40);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 6);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 32);
|
||||
ammma = ammma.createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE, 5);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_KNOCKBACK, 1.5);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends MonsterEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 10;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.2, true) {
|
||||
@Override
|
||||
protected double getAttackReachSqr(LivingEntity entity) {
|
||||
return (double) (4.0 + entity.getWidth() * entity.getWidth());
|
||||
}
|
||||
});
|
||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, ServerPlayerEntity.class, false, false));
|
||||
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, PlayerEntity.class, false, false));
|
||||
this.targetSelector.addGoal(4, new HurtByTargetGoal(this).setCallsForHelp());
|
||||
this.goalSelector.addGoal(5, new RandomWalkingGoal(this, 0.8));
|
||||
this.goalSelector.addGoal(6, new LookAtGoal(this, ServerPlayerEntity.class, (float) 32));
|
||||
this.goalSelector.addGoal(7, new LookRandomlyGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.fire.extinguish"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playStepSound(BlockPos pos, BlockState blockIn) {
|
||||
this.playSound((net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.anvil.step")), 0.15f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.anvil.land"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.firework_rocket.large_blast"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
Entity sourceentity = source.getTrueSource();
|
||||
|
||||
EmberleafMilitaryBotEntityIsHurtProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(DamageSource source) {
|
||||
super.onDeath(source);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity sourceentity = source.getTrueSource();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryBotEntityDiesProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryBotOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryRobotLowerHalfOnInitialEntitySpawnProcedure;
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryRobotLowerHalfOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.EmberleafMilitaryRobotLowerHalfRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IServerWorld;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.ILivingEntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class EmberleafMilitaryRobotLowerHalfEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.MONSTER)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).immuneToFire()
|
||||
.size(0.6f, 1.8f)).build("emberleaf_military_robot_lower_half").setRegistryName("emberleaf_military_robot_lower_half");
|
||||
|
||||
public EmberleafMilitaryRobotLowerHalfEntity(HemModElements instance) {
|
||||
super(instance, 61);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EmberleafMilitaryRobotLowerHalfRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC))
|
||||
.setRegistryName("emberleaf_military_robot_lower_half_spawn_egg"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.4);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 10);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new WaterAvoidingRandomWalkingGoal(this, 0.7));
|
||||
this.goalSelector.addGoal(2, new AvoidEntityGoal(this, ServerPlayerEntity.class, (float) 16, 1, 1.2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.firework_rocket.blast"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.anvil.land"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.explode"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILivingEntityData onInitialSpawn(IServerWorld world, DifficultyInstance difficulty, SpawnReason reason,
|
||||
@Nullable ILivingEntityData livingdata, @Nullable CompoundNBT tag) {
|
||||
ILivingEntityData retval = super.onInitialSpawn(world, difficulty, reason, livingdata, tag);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryRobotLowerHalfOnInitialEntitySpawnProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryRobotLowerHalfOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryRobotLowerHalfOnInitialEntitySpawnProcedure;
|
||||
import studio.halbear.hem.procedures.EmberleafMilitaryRobotLowerHalfOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.EmberleafMilitaryRobotUpperHalfRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IServerWorld;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.ILivingEntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class EmberleafMilitaryRobotUpperHalfEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.MONSTER)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).immuneToFire()
|
||||
.size(1.2f, 1.5f)).build("emberleaf_military_robot_upper_half").setRegistryName("emberleaf_military_robot_upper_half");
|
||||
|
||||
public EmberleafMilitaryRobotUpperHalfEntity(HemModElements instance) {
|
||||
super(instance, 62);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EmberleafMilitaryRobotUpperHalfRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC))
|
||||
.setRegistryName("emberleaf_military_robot_upper_half_spawn_egg"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.4);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 10);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new WaterAvoidingRandomWalkingGoal(this, 0.7));
|
||||
this.goalSelector.addGoal(2, new AvoidEntityGoal(this, ServerPlayerEntity.class, (float) 16, 1, 1.2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.firework_rocket.blast"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.anvil.land"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.explode"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source.getImmediateSource() instanceof AbstractArrowEntity)
|
||||
return false;
|
||||
if (source.getImmediateSource() instanceof PlayerEntity)
|
||||
return false;
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.DROWN)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source.isExplosion())
|
||||
return false;
|
||||
if (source.getDamageType().equals("trident"))
|
||||
return false;
|
||||
if (source == DamageSource.ANVIL)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILivingEntityData onInitialSpawn(IServerWorld world, DifficultyInstance difficulty, SpawnReason reason,
|
||||
@Nullable ILivingEntityData livingdata, @Nullable CompoundNBT tag) {
|
||||
ILivingEntityData retval = super.onInitialSpawn(world, difficulty, reason, livingdata, tag);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryRobotLowerHalfOnInitialEntitySpawnProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
EmberleafMilitaryRobotLowerHalfOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.FluffaloRightClickedOnEntityProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.entity.renderer.FluffaloRenderer;
|
||||
import studio.halbear.hem.block.BlueleafWheatBlock;
|
||||
import studio.halbear.hem.block.BlueleafLavenderBlock;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.projectile.AbstractArrowEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.ai.goal.TemptGoal;
|
||||
import net.minecraft.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
|
||||
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
|
||||
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class FluffaloEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.CREATURE)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(2f, 2f))
|
||||
.build("fluffalo").setRegistryName("fluffalo");
|
||||
|
||||
public FluffaloEntity(HemModElements instance) {
|
||||
super(instance, 162);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FluffaloRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items.add(() -> new SpawnEggItem(entity, -10079488, -3381760, new Item.Properties().group(BlueleafTabItemGroup.tab))
|
||||
.setRegistryName("fluffalo_spawn_egg"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_hayfever_fields").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:heightend_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getSpawns().getSpawner(EntityClassification.CREATURE).add(new MobSpawnInfo.Spawners(entity, 10, 1, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
|
||||
(entityType, world, reason, pos,
|
||||
random) -> (world.getBlockState(pos.down()).getMaterial() == Material.ORGANIC && world.getLightSubtracted(pos, 0) > 8));
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.35);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 50);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends MonsterEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 5;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new RandomWalkingGoal(this, 0.5));
|
||||
this.goalSelector.addGoal(2, new TemptGoal(this, 0.4, Ingredient.fromItems(BlueleafLavenderBlock.block.asItem()), false));
|
||||
this.goalSelector.addGoal(3, new TemptGoal(this, 0.4, Ingredient.fromItems(BlueleafWheatBlock.block.asItem()), false));
|
||||
this.targetSelector.addGoal(4, new HurtByTargetGoal(this).setCallsForHelp());
|
||||
this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1, false) {
|
||||
@Override
|
||||
protected double getAttackReachSqr(LivingEntity entity) {
|
||||
return (double) (4.0 + entity.getWidth() * entity.getWidth());
|
||||
}
|
||||
});
|
||||
this.goalSelector.addGoal(7, new LookRandomlyGoal(this));
|
||||
this.goalSelector.addGoal(8, new SwimGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.cow.ambient"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.cow.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.cow.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source.getImmediateSource() instanceof AbstractArrowEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.ANVIL)
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType func_230254_b_(PlayerEntity sourceentity, Hand hand) {
|
||||
ItemStack itemstack = sourceentity.getHeldItem(hand);
|
||||
ActionResultType retval = ActionResultType.func_233537_a_(this.world.isRemote());
|
||||
super.func_230254_b_(sourceentity, hand);
|
||||
sourceentity.startRiding(this);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
FluffaloRightClickedOnEntityProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity),
|
||||
new AbstractMap.SimpleEntry<>("sourceentity", sourceentity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.FluffaloShavedOnInitialEntitySpawnProcedure;
|
||||
import studio.halbear.hem.procedures.FluffaloShavedOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.FluffaloShavedRenderer;
|
||||
import studio.halbear.hem.block.BlueleafWheatBlock;
|
||||
import studio.halbear.hem.block.BlueleafLavenderBlock;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IServerWorld;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.ai.goal.TemptGoal;
|
||||
import net.minecraft.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
|
||||
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
|
||||
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ILivingEntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class FluffaloShavedEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.CREATURE)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(2f, 2f))
|
||||
.build("fluffalo_shaved").setRegistryName("fluffalo_shaved");
|
||||
|
||||
public FluffaloShavedEntity(HemModElements instance) {
|
||||
super(instance, 268);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new FluffaloShavedRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.35);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 25);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends MonsterEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 5;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new RandomWalkingGoal(this, 0.5));
|
||||
this.goalSelector.addGoal(2, new TemptGoal(this, 0.4, Ingredient.fromItems(BlueleafLavenderBlock.block.asItem()), false));
|
||||
this.goalSelector.addGoal(3, new TemptGoal(this, 0.4, Ingredient.fromItems(BlueleafWheatBlock.block.asItem()), false));
|
||||
this.targetSelector.addGoal(4, new HurtByTargetGoal(this).setCallsForHelp());
|
||||
this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1, false) {
|
||||
@Override
|
||||
protected double getAttackReachSqr(LivingEntity entity) {
|
||||
return (double) (4.0 + entity.getWidth() * entity.getWidth());
|
||||
}
|
||||
});
|
||||
this.goalSelector.addGoal(7, new LookRandomlyGoal(this));
|
||||
this.goalSelector.addGoal(8, new SwimGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.cow.ambient"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.cow.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.cow.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.ANVIL)
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILivingEntityData onInitialSpawn(IServerWorld world, DifficultyInstance difficulty, SpawnReason reason,
|
||||
@Nullable ILivingEntityData livingdata, @Nullable CompoundNBT tag) {
|
||||
ILivingEntityData retval = super.onInitialSpawn(world, difficulty, reason, livingdata, tag);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
FluffaloShavedOnInitialEntitySpawnProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType func_230254_b_(PlayerEntity sourceentity, Hand hand) {
|
||||
ItemStack itemstack = sourceentity.getHeldItem(hand);
|
||||
ActionResultType retval = ActionResultType.func_233537_a_(this.world.isRemote());
|
||||
super.func_230254_b_(sourceentity, hand);
|
||||
sourceentity.startRiding(this);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
FluffaloShavedOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.GiantButterflyOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.GiantButterflyRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.pathfinding.FlyingPathNavigator;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
|
||||
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
|
||||
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
|
||||
import net.minecraft.entity.ai.goal.Goal;
|
||||
import net.minecraft.entity.ai.controller.FlyingMovementController;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class GiantButterflyEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.CREATURE)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(1f, 1f))
|
||||
.build("giant_butterfly").setRegistryName("giant_butterfly");
|
||||
|
||||
public GiantButterflyEntity(HemModElements instance) {
|
||||
super(instance, 44);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new GiantButterflyRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.4);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 35);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 4);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FLYING_SPEED, 0.4);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 1;
|
||||
setNoAI(false);
|
||||
this.moveController = new FlyingMovementController(this, 10, true);
|
||||
this.navigator = new FlyingPathNavigator(this, this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setCallsForHelp());
|
||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, LadyBugInFlightEntity.CustomEntity.class, false, false));
|
||||
this.goalSelector.addGoal(3, new Goal() {
|
||||
{
|
||||
this.setMutexFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
|
||||
public boolean shouldExecute() {
|
||||
if (CustomEntity.this.getAttackTarget() != null && !CustomEntity.this.getMoveHelper().isUpdating()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldContinueExecuting() {
|
||||
return CustomEntity.this.getMoveHelper().isUpdating() && CustomEntity.this.getAttackTarget() != null
|
||||
&& CustomEntity.this.getAttackTarget().isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting() {
|
||||
LivingEntity livingentity = CustomEntity.this.getAttackTarget();
|
||||
Vector3d vec3d = livingentity.getEyePosition(1);
|
||||
CustomEntity.this.moveController.setMoveTo(vec3d.x, vec3d.y, vec3d.z, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
LivingEntity livingentity = CustomEntity.this.getAttackTarget();
|
||||
if (CustomEntity.this.getBoundingBox().intersects(livingentity.getBoundingBox())) {
|
||||
CustomEntity.this.attackEntityAsMob(livingentity);
|
||||
} else {
|
||||
double d0 = CustomEntity.this.getDistanceSq(livingentity);
|
||||
if (d0 < 16) {
|
||||
Vector3d vec3d = livingentity.getEyePosition(1);
|
||||
CustomEntity.this.moveController.setMoveTo(vec3d.x, vec3d.y, vec3d.z, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.goalSelector.addGoal(4, new RandomWalkingGoal(this, 1, 20) {
|
||||
@Override
|
||||
protected Vector3d getPosition() {
|
||||
Random random = CustomEntity.this.getRNG();
|
||||
double dir_x = CustomEntity.this.getPosX() + ((random.nextFloat() * 2 - 1) * 16);
|
||||
double dir_y = CustomEntity.this.getPosY() + ((random.nextFloat() * 2 - 1) * 16);
|
||||
double dir_z = CustomEntity.this.getPosZ() + ((random.nextFloat() * 2 - 1) * 16);
|
||||
return new Vector3d(dir_x, dir_y, dir_z);
|
||||
}
|
||||
});
|
||||
this.goalSelector.addGoal(5, new LookRandomlyGoal(this));
|
||||
this.goalSelector.addGoal(6, new SwimGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLivingFall(float l, float d) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType func_230254_b_(PlayerEntity sourceentity, Hand hand) {
|
||||
ItemStack itemstack = sourceentity.getHeldItem(hand);
|
||||
ActionResultType retval = ActionResultType.func_233537_a_(this.world.isRemote());
|
||||
super.func_230254_b_(sourceentity, hand);
|
||||
sourceentity.startRiding(this);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
GiantButterflyOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoGravity(boolean ignored) {
|
||||
super.setNoGravity(true);
|
||||
}
|
||||
|
||||
public void livingTick() {
|
||||
super.livingTick();
|
||||
this.setNoGravity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.GiantButterflyWalkingOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.procedures.GiantButterflyWalkingNaturalEntitySpawningConditionProcedure;
|
||||
import studio.halbear.hem.entity.renderer.GiantButterflyWalkingRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
|
||||
import net.minecraft.entity.ai.goal.LookAtGoal;
|
||||
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
|
||||
import net.minecraft.entity.ai.goal.FollowMobGoal;
|
||||
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class GiantButterflyWalkingEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.CREATURE)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new)
|
||||
.size(1f, 1.2000000000000002f)).build("giant_butterfly_walking").setRegistryName("giant_butterfly_walking");
|
||||
|
||||
public GiantButterflyWalkingEntity(HemModElements instance) {
|
||||
super(instance, 45);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new GiantButterflyWalkingRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_hayfever_fields").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getSpawns().getSpawner(EntityClassification.CREATURE).add(new MobSpawnInfo.Spawners(entity, 5, 1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
|
||||
(entityType, world, reason, pos, random) -> {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
return GiantButterflyWalkingNaturalEntitySpawningConditionProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x),
|
||||
new AbstractMap.SimpleEntry<>("y", y), new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
});
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.2);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 35);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 4);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 1;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setCallsForHelp());
|
||||
this.goalSelector.addGoal(2, new AvoidEntityGoal(this, ServerPlayerEntity.class, (float) 6, 1, 1));
|
||||
this.goalSelector.addGoal(3, new FollowMobGoal(this, (float) 1, 10, 5));
|
||||
this.goalSelector.addGoal(4, new LookAtGoal(this, LadybugEntity.CustomEntity.class, (float) 6));
|
||||
this.goalSelector.addGoal(5, new RandomWalkingGoal(this, 1));
|
||||
this.goalSelector.addGoal(6, new LookRandomlyGoal(this));
|
||||
this.goalSelector.addGoal(7, new SwimGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType func_230254_b_(PlayerEntity sourceentity, Hand hand) {
|
||||
ItemStack itemstack = sourceentity.getHeldItem(hand);
|
||||
ActionResultType retval = ActionResultType.func_233537_a_(this.world.isRemote());
|
||||
super.func_230254_b_(sourceentity, hand);
|
||||
sourceentity.startRiding(this);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
GiantButterflyWalkingOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.TigerFishOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.item.TigerFishItemItem;
|
||||
import studio.halbear.hem.entity.renderer.GoldFishRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.pathfinding.SwimmerPathNavigator;
|
||||
import net.minecraft.pathfinding.PathNodeType;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.passive.SquidEntity;
|
||||
import net.minecraft.entity.ai.goal.RandomSwimmingGoal;
|
||||
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
|
||||
import net.minecraft.entity.ai.controller.MovementController;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class GoldFishEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.WATER_CREATURE)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new)
|
||||
.size(0.3f, 0.4f)).build("gold_fish").setRegistryName("gold_fish");
|
||||
|
||||
public GoldFishEntity(HemModElements instance) {
|
||||
super(instance, 132);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new GoldFishRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items
|
||||
.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("gold_fish_spawn_egg"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getSpawns().getSpawner(EntityClassification.WATER_CREATURE).add(new MobSpawnInfo.Spawners(entity, 15, 1, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
|
||||
SquidEntity::func_223365_b);
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 10);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
ammma = ammma.createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE, 0.5);
|
||||
ammma = ammma.createMutableAttribute(ForgeMod.SWIM_SPEED.get(), 0.7);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
this.setPathPriority(PathNodeType.WATER, 0);
|
||||
this.moveController = new MovementController(this) {
|
||||
@Override
|
||||
public void tick() {
|
||||
if (CustomEntity.this.isInWater())
|
||||
CustomEntity.this.setMotion(CustomEntity.this.getMotion().add(0, 0.005, 0));
|
||||
if (this.action == MovementController.Action.MOVE_TO && !CustomEntity.this.getNavigator().noPath()) {
|
||||
double dx = this.posX - CustomEntity.this.getPosX();
|
||||
double dy = this.posY - CustomEntity.this.getPosY();
|
||||
double dz = this.posZ - CustomEntity.this.getPosZ();
|
||||
float f = (float) (MathHelper.atan2(dz, dx) * (double) (180 / Math.PI)) - 90;
|
||||
float f1 = (float) (this.speed * CustomEntity.this.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
||||
CustomEntity.this.rotationYaw = this.limitAngle(CustomEntity.this.rotationYaw, f, 10);
|
||||
CustomEntity.this.renderYawOffset = CustomEntity.this.rotationYaw;
|
||||
CustomEntity.this.rotationYawHead = CustomEntity.this.rotationYaw;
|
||||
if (CustomEntity.this.isInWater()) {
|
||||
CustomEntity.this.setAIMoveSpeed((float) CustomEntity.this.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
||||
float f2 = -(float) (MathHelper.atan2(dy, MathHelper.sqrt(dx * dx + dz * dz)) * (180F / Math.PI));
|
||||
f2 = MathHelper.clamp(MathHelper.wrapDegrees(f2), -85, 85);
|
||||
CustomEntity.this.rotationPitch = this.limitAngle(CustomEntity.this.rotationPitch, f2, 5);
|
||||
float f3 = MathHelper.cos(CustomEntity.this.rotationPitch * (float) (Math.PI / 180.0));
|
||||
CustomEntity.this.setMoveForward(f3 * f1);
|
||||
CustomEntity.this.setMoveVertical((float) (f1 * dy));
|
||||
} else {
|
||||
CustomEntity.this.setAIMoveSpeed(f1 * 0.05F);
|
||||
}
|
||||
} else {
|
||||
CustomEntity.this.setAIMoveSpeed(0);
|
||||
CustomEntity.this.setMoveVertical(0);
|
||||
CustomEntity.this.setMoveForward(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.navigator = new SwimmerPathNavigator(this, this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new RandomSwimmingGoal(this, 12, 40));
|
||||
this.goalSelector.addGoal(2, new AvoidEntityGoal(this, ServerPlayerEntity.class, (float) 6, 16, 12));
|
||||
this.goalSelector.addGoal(3, new AvoidEntityGoal(this, TigerFishEntity.CustomEntity.class, (float) 6, 12, 12));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.WATER;
|
||||
}
|
||||
|
||||
protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
|
||||
super.dropSpecialItems(source, looting, recentlyHitIn);
|
||||
this.entityDropItem(new ItemStack(TigerFishItemItem.block));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.bubble_column.bubble_pop"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playStepSound(BlockPos pos, BlockState blockIn) {
|
||||
this.playSound((net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS
|
||||
.getValue(new ResourceLocation("ambient.underwater.loop.additions.ultra_rare")), 0.15f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.DROWN)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
TigerFishOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreatheUnderwater() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotColliding(IWorldReader world) {
|
||||
return world.checkNoEntityCollision(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPushedByWater() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.HotAirBalloonRightClickedOnEntityProcedure;
|
||||
import studio.halbear.hem.procedures.HotAirBalloonOnInitialEntitySpawnProcedure;
|
||||
import studio.halbear.hem.procedures.HotAirBalloonOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.HotAirBalloonRenderer;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IServerWorld;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.pathfinding.FlyingPathNavigator;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.entity.ai.controller.FlyingMovementController;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.ILivingEntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class HotAirBalloonEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.MONSTER)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(3f, 8f))
|
||||
.build("hot_air_balloon").setRegistryName("hot_air_balloon");
|
||||
|
||||
public HotAirBalloonEntity(HemModElements instance) {
|
||||
super(instance, 163);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new HotAirBalloonRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 10);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FLYING_SPEED, 0.3);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
enablePersistence();
|
||||
this.moveController = new FlyingMovementController(this, 10, true);
|
||||
this.navigator = new FlyingPathNavigator(this, this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new SwimGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDespawn(double distanceToClosestPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMountedYOffset() {
|
||||
return super.getMountedYOffset() + -5.8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLivingFall(float l, float d) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.DROWN)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
if (source == DamageSource.WITHER)
|
||||
return false;
|
||||
if (source.getDamageType().equals("witherSkull"))
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILivingEntityData onInitialSpawn(IServerWorld world, DifficultyInstance difficulty, SpawnReason reason,
|
||||
@Nullable ILivingEntityData livingdata, @Nullable CompoundNBT tag) {
|
||||
ILivingEntityData retval = super.onInitialSpawn(world, difficulty, reason, livingdata, tag);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
HotAirBalloonOnInitialEntitySpawnProcedure
|
||||
.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType func_230254_b_(PlayerEntity sourceentity, Hand hand) {
|
||||
ItemStack itemstack = sourceentity.getHeldItem(hand);
|
||||
ActionResultType retval = ActionResultType.func_233537_a_(this.world.isRemote());
|
||||
super.func_230254_b_(sourceentity, hand);
|
||||
sourceentity.startRiding(this);
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
HotAirBalloonRightClickedOnEntityProcedure.executeProcedure(
|
||||
Stream.of(new AbstractMap.SimpleEntry<>("entity", entity), new AbstractMap.SimpleEntry<>("sourceentity", sourceentity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
HotAirBalloonOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoGravity(boolean ignored) {
|
||||
super.setNoGravity(true);
|
||||
}
|
||||
|
||||
public void livingTick() {
|
||||
super.livingTick();
|
||||
this.setNoGravity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.LadyBugInFlightOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.LadyBugInFlightRenderer;
|
||||
import studio.halbear.hem.block.BlueleafWheatBlock;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.pathfinding.FlyingPathNavigator;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
|
||||
import net.minecraft.entity.ai.goal.BreakBlockGoal;
|
||||
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
|
||||
import net.minecraft.entity.ai.controller.FlyingMovementController;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Random;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class LadyBugInFlightEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.AMBIENT)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(32).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new)
|
||||
.size(0.4f, 0.3f)).build("lady_bug_in_flight").setRegistryName("lady_bug_in_flight");
|
||||
|
||||
public LadyBugInFlightEntity(HemModElements instance) {
|
||||
super(instance, 38);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new LadyBugInFlightRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.5);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 2);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 1);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 8);
|
||||
ammma = ammma.createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE, 5);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FLYING_SPEED, 0.5);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
this.moveController = new FlyingMovementController(this, 10, true);
|
||||
this.navigator = new FlyingPathNavigator(this, this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new AvoidEntityGoal(this, GiantButterflyEntity.CustomEntity.class, (float) 6, 1.3, 1));
|
||||
this.goalSelector.addGoal(2, new AvoidEntityGoal(this, ServerPlayerEntity.class, (float) 6, 1, 0.6));
|
||||
this.goalSelector.addGoal(3, new RandomWalkingGoal(this, 0.8, 20) {
|
||||
@Override
|
||||
protected Vector3d getPosition() {
|
||||
Random random = CustomEntity.this.getRNG();
|
||||
double dir_x = CustomEntity.this.getPosX() + ((random.nextFloat() * 2 - 1) * 16);
|
||||
double dir_y = CustomEntity.this.getPosY() + ((random.nextFloat() * 2 - 1) * 16);
|
||||
double dir_z = CustomEntity.this.getPosZ() + ((random.nextFloat() * 2 - 1) * 16);
|
||||
return new Vector3d(dir_x, dir_y, dir_z);
|
||||
}
|
||||
});
|
||||
this.goalSelector.addGoal(4, new BreakBlockGoal(BlueleafWheatBlock.block, this, 1, (int) 3));
|
||||
this.goalSelector.addGoal(5, new LookRandomlyGoal(this));
|
||||
this.goalSelector.addGoal(6, new SwimGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.bee.pollinate"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.bee.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.bee.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLivingFall(float l, float d) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
LadyBugInFlightOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFallState(double y, boolean onGroundIn, BlockState state, BlockPos pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoGravity(boolean ignored) {
|
||||
super.setNoGravity(true);
|
||||
}
|
||||
|
||||
public void livingTick() {
|
||||
super.livingTick();
|
||||
this.setNoGravity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.LadybugOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.entity.renderer.LadybugRenderer;
|
||||
import studio.halbear.hem.block.AntsBlock;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.entity.projectile.PotionEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.SwimGoal;
|
||||
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
|
||||
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
|
||||
import net.minecraft.entity.ai.goal.BreakBlockGoal;
|
||||
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureEntity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class LadybugEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.CREATURE)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(32).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new)
|
||||
.size(0.4f, 0.3f)).build("ladybug").setRegistryName("ladybug");
|
||||
|
||||
public LadybugEntity(HemModElements instance) {
|
||||
super(instance, 37);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new LadybugRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_plains").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (new ResourceLocation("hem:blueleaf_hayfever_fields").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getSpawns().getSpawner(EntityClassification.CREATURE).add(new MobSpawnInfo.Spawners(entity, 20, 1, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
|
||||
(entityType, world, reason, pos,
|
||||
random) -> (world.getBlockState(pos.down()).getMaterial() == Material.ORGANIC && world.getLightSubtracted(pos, 0) > 8));
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.4);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 2);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 1);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 0);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 8);
|
||||
ammma = ammma.createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE, 5);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends CreatureEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.goalSelector.addGoal(1, new AvoidEntityGoal(this, ServerPlayerEntity.class, (float) 6, 1, 0.6));
|
||||
this.goalSelector.addGoal(2, new BreakBlockGoal(AntsBlock.block, this, 1, (int) 3));
|
||||
this.goalSelector.addGoal(3, new WaterAvoidingRandomWalkingGoal(this, 0.4));
|
||||
this.goalSelector.addGoal(4, new RandomWalkingGoal(this, 0.4));
|
||||
this.goalSelector.addGoal(5, new LookRandomlyGoal(this));
|
||||
this.goalSelector.addGoal(6, new SwimGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.bee.pollinate"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.bee.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.bee.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source.getImmediateSource() instanceof PotionEntity || source.getImmediateSource() instanceof AreaEffectCloudEntity)
|
||||
return false;
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
LadybugOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
|
||||
package studio.halbear.hem.entity;
|
||||
|
||||
import studio.halbear.hem.procedures.TigerFishOnEntityTickUpdateProcedure;
|
||||
import studio.halbear.hem.item.TigerFishItemItem;
|
||||
import studio.halbear.hem.entity.renderer.TigerFishRenderer;
|
||||
import studio.halbear.hem.block.GiantLilyPadBlock;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fml.network.FMLPlayMessages;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.biome.MobSpawnInfo;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.pathfinding.SwimmerPathNavigator;
|
||||
import net.minecraft.pathfinding.PathNodeType;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.passive.SquidEntity;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.entity.ai.goal.TemptGoal;
|
||||
import net.minecraft.entity.ai.goal.RestrictSunGoal;
|
||||
import net.minecraft.entity.ai.goal.RandomSwimmingGoal;
|
||||
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
|
||||
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
|
||||
import net.minecraft.entity.ai.goal.BreedGoal;
|
||||
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
|
||||
import net.minecraft.entity.ai.controller.MovementController;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.ILivingEntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.CreatureAttribute;
|
||||
import net.minecraft.entity.AgeableEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class TigerFishEntity extends HemModElements.ModElement {
|
||||
public static EntityType entity = (EntityType.Builder.<CustomEntity>create(CustomEntity::new, EntityClassification.WATER_CREATURE)
|
||||
.setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(CustomEntity::new).size(1f, 0.4f))
|
||||
.build("tiger_fish").setRegistryName("tiger_fish");
|
||||
|
||||
public TigerFishEntity(HemModElements instance) {
|
||||
super(instance, 122);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new TigerFishRenderer.ModelRegisterHandler());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new EntityAttributesRegisterHandler());
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.entities.add(() -> entity);
|
||||
elements.items
|
||||
.add(() -> new SpawnEggItem(entity, -1, -1, new Item.Properties().group(ItemGroup.MISC)).setRegistryName("tiger_fish_spawn_egg"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void addFeatureToBiomes(BiomeLoadingEvent event) {
|
||||
boolean biomeCriteria = false;
|
||||
if (new ResourceLocation("hem:lush_blueleaf_marsh").equals(event.getName()))
|
||||
biomeCriteria = true;
|
||||
if (!biomeCriteria)
|
||||
return;
|
||||
event.getSpawns().getSpawner(EntityClassification.WATER_CREATURE).add(new MobSpawnInfo.Spawners(entity, 15, 1, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
EntitySpawnPlacementRegistry.register(entity, EntitySpawnPlacementRegistry.PlacementType.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES,
|
||||
SquidEntity::func_223365_b);
|
||||
}
|
||||
|
||||
private static class EntityAttributesRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void onEntityAttributeCreation(EntityAttributeCreationEvent event) {
|
||||
AttributeModifierMap.MutableAttribute ammma = MobEntity.func_233666_p_();
|
||||
ammma = ammma.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.MAX_HEALTH, 20);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ARMOR, 3);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_DAMAGE, 6);
|
||||
ammma = ammma.createMutableAttribute(Attributes.FOLLOW_RANGE, 16);
|
||||
ammma = ammma.createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE, 0.5);
|
||||
ammma = ammma.createMutableAttribute(Attributes.ATTACK_KNOCKBACK, 0.3);
|
||||
ammma = ammma.createMutableAttribute(ForgeMod.SWIM_SPEED.get(), 0.5);
|
||||
event.put(entity, ammma.create());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomEntity extends AnimalEntity {
|
||||
public CustomEntity(FMLPlayMessages.SpawnEntity packet, World world) {
|
||||
this(entity, world);
|
||||
}
|
||||
|
||||
public CustomEntity(EntityType<CustomEntity> type, World world) {
|
||||
super(type, world);
|
||||
experienceValue = 0;
|
||||
setNoAI(false);
|
||||
this.setPathPriority(PathNodeType.WATER, 0);
|
||||
this.moveController = new MovementController(this) {
|
||||
@Override
|
||||
public void tick() {
|
||||
if (CustomEntity.this.isInWater())
|
||||
CustomEntity.this.setMotion(CustomEntity.this.getMotion().add(0, 0.005, 0));
|
||||
if (this.action == MovementController.Action.MOVE_TO && !CustomEntity.this.getNavigator().noPath()) {
|
||||
double dx = this.posX - CustomEntity.this.getPosX();
|
||||
double dy = this.posY - CustomEntity.this.getPosY();
|
||||
double dz = this.posZ - CustomEntity.this.getPosZ();
|
||||
float f = (float) (MathHelper.atan2(dz, dx) * (double) (180 / Math.PI)) - 90;
|
||||
float f1 = (float) (this.speed * CustomEntity.this.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
||||
CustomEntity.this.rotationYaw = this.limitAngle(CustomEntity.this.rotationYaw, f, 10);
|
||||
CustomEntity.this.renderYawOffset = CustomEntity.this.rotationYaw;
|
||||
CustomEntity.this.rotationYawHead = CustomEntity.this.rotationYaw;
|
||||
if (CustomEntity.this.isInWater()) {
|
||||
CustomEntity.this.setAIMoveSpeed((float) CustomEntity.this.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
||||
float f2 = -(float) (MathHelper.atan2(dy, MathHelper.sqrt(dx * dx + dz * dz)) * (180F / Math.PI));
|
||||
f2 = MathHelper.clamp(MathHelper.wrapDegrees(f2), -85, 85);
|
||||
CustomEntity.this.rotationPitch = this.limitAngle(CustomEntity.this.rotationPitch, f2, 5);
|
||||
float f3 = MathHelper.cos(CustomEntity.this.rotationPitch * (float) (Math.PI / 180.0));
|
||||
CustomEntity.this.setMoveForward(f3 * f1);
|
||||
CustomEntity.this.setMoveVertical((float) (f1 * dy));
|
||||
} else {
|
||||
CustomEntity.this.setAIMoveSpeed(f1 * 0.05F);
|
||||
}
|
||||
} else {
|
||||
CustomEntity.this.setAIMoveSpeed(0);
|
||||
CustomEntity.this.setMoveVertical(0);
|
||||
CustomEntity.this.setMoveForward(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.navigator = new SwimmerPathNavigator(this, this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal(this, GoldFishEntity.CustomEntity.class, false, true));
|
||||
this.goalSelector.addGoal(2, new TemptGoal(this, 8, Ingredient.fromItems(GiantLilyPadBlock.block.asItem()), true));
|
||||
this.goalSelector.addGoal(3, new AvoidEntityGoal(this, ServerPlayerEntity.class, (float) 6, 8, 8));
|
||||
this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 8, 40));
|
||||
this.goalSelector.addGoal(5, new RestrictSunGoal(this));
|
||||
this.goalSelector.addGoal(6, new BreedGoal(this, 1));
|
||||
this.targetSelector.addGoal(7, new HurtByTargetGoal(this).setCallsForHelp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttribute getCreatureAttribute() {
|
||||
return CreatureAttribute.WATER;
|
||||
}
|
||||
|
||||
protected void dropSpecialItems(DamageSource source, int looting, boolean recentlyHitIn) {
|
||||
super.dropSpecialItems(source, looting, recentlyHitIn);
|
||||
this.entityDropItem(new ItemStack(TigerFishItemItem.block));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getAmbientSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.bubble_column.bubble_pop"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playStepSound(BlockPos pos, BlockState blockIn) {
|
||||
this.playSound((net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS
|
||||
.getValue(new ResourceLocation("ambient.underwater.loop.additions.ultra_rare")), 0.15f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.util.SoundEvent getDeathSound() {
|
||||
return (net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source == DamageSource.FALL)
|
||||
return false;
|
||||
if (source == DamageSource.CACTUS)
|
||||
return false;
|
||||
if (source == DamageSource.DROWN)
|
||||
return false;
|
||||
if (source == DamageSource.LIGHTNING_BOLT)
|
||||
return false;
|
||||
if (source == DamageSource.DRAGON_BREATH)
|
||||
return false;
|
||||
return super.attackEntityFrom(source, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
double x = this.getPosX();
|
||||
double y = this.getPosY();
|
||||
double z = this.getPosZ();
|
||||
Entity entity = this;
|
||||
|
||||
TigerFishOnEntityTickUpdateProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgeableEntity func_241840_a(ServerWorld serverWorld, AgeableEntity ageable) {
|
||||
CustomEntity retval = (CustomEntity) entity.create(serverWorld);
|
||||
retval.onInitialSpawn(serverWorld, serverWorld.getDifficultyForLocation(new BlockPos(retval.getPosition())), SpawnReason.BREEDING,
|
||||
(ILivingEntityData) null, (CompoundNBT) null);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBreedingItem(ItemStack stack) {
|
||||
if (stack == null)
|
||||
return false;
|
||||
if (GiantLilyPadBlock.block.asItem() == stack.getItem())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreatheUnderwater() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotColliding(IWorldReader world) {
|
||||
return world.checkNoEntityCollision(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPushedByWater() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+151
@@ -0,0 +1,151 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.procedures.DormantAgedEmberleafMilitaryBotEntityShakingConditionProcedure;
|
||||
import studio.halbear.hem.entity.DormantAgedEmberleafMilitaryBotEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class DormantAgedEmberleafMilitaryBotRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(DormantAgedEmberleafMilitaryBotEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelEmberleafMilitaryBotAgedDormant(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/emberleafmilitaryrobotaged.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean func_230495_a_(LivingEntity _ent) {
|
||||
Entity entity = _ent;
|
||||
World world = entity.world;
|
||||
double x = entity.getPosX();
|
||||
double y = entity.getPosY();
|
||||
double z = entity.getPosZ();
|
||||
return DormantAgedEmberleafMilitaryBotEntityShakingConditionProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x),
|
||||
new AbstractMap.SimpleEntry<>("y", y), new AbstractMap.SimpleEntry<>("z", z))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.5
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelEmberleafMilitaryBotAgedDormant extends EntityModel<Entity> {
|
||||
private final ModelRenderer bone;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer LeftLeg;
|
||||
private final ModelRenderer RightLeg;
|
||||
private final ModelRenderer UpperBody;
|
||||
private final ModelRenderer leftArm;
|
||||
private final ModelRenderer rightArm;
|
||||
private final ModelRenderer HeadX;
|
||||
private final ModelRenderer cube_r2;
|
||||
|
||||
public ModelEmberleafMilitaryBotAgedDormant() {
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
bone = new ModelRenderer(this);
|
||||
bone.setRotationPoint(0.0F, 24.25F, 0.0F);
|
||||
setRotationAngle(bone, 0.0F, 0.0F, 0.0436F);
|
||||
bone.setTextureOffset(17, 75).addBox(-4.0F, -28.0F, -2.0F, 8.0F, 6.0F, 4.0F, 0.0F, false);
|
||||
bone.setTextureOffset(76, 0).addBox(-2.0F, -22.0F, -2.0F, 4.0F, 5.0F, 4.0F, 0.0F, false);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, -31.0F, 0.0F);
|
||||
bone.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0F, 0.0F, -3.1416F);
|
||||
cube_r1.setTextureOffset(17, 76).addBox(-4.0F, -3.0F, -2.0F, 8.0F, 3.0F, 4.0F, 0.0F, false);
|
||||
LeftLeg = new ModelRenderer(this);
|
||||
LeftLeg.setRotationPoint(-1.75F, -19.25F, 0.0F);
|
||||
bone.addChild(LeftLeg);
|
||||
LeftLeg.setTextureOffset(24, 47).addBox(-5.25F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, false);
|
||||
LeftLeg.setTextureOffset(0, 75).addBox(-4.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, false);
|
||||
RightLeg = new ModelRenderer(this);
|
||||
RightLeg.setRotationPoint(1.75F, -19.25F, 0.0F);
|
||||
bone.addChild(RightLeg);
|
||||
setRotationAngle(RightLeg, 0.0F, 0.0F, -0.0873F);
|
||||
RightLeg.setTextureOffset(24, 47).addBox(-0.75F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, true);
|
||||
RightLeg.setTextureOffset(0, 75).addBox(0.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, true);
|
||||
UpperBody = new ModelRenderer(this);
|
||||
UpperBody.setRotationPoint(0.0F, -29.5F, 0.0F);
|
||||
bone.addChild(UpperBody);
|
||||
setRotationAngle(UpperBody, 0.5672F, 0.0F, 0.0F);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(-11.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(8.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, true);
|
||||
UpperBody.setTextureOffset(68, 38).addBox(4.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(0, 111).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.25F, false);
|
||||
UpperBody.setTextureOffset(0, 0).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(56, 27).addBox(-13.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(44, 0).addBox(-1.5F, -16.5F, -1.5F, 3.0F, 7.0F, 3.0F, 0.0F, false);
|
||||
leftArm = new ModelRenderer(this);
|
||||
leftArm.setRotationPoint(-10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(leftArm);
|
||||
setRotationAngle(leftArm, -0.5655F, -0.0468F, -0.0737F);
|
||||
leftArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, false);
|
||||
leftArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, false);
|
||||
leftArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, false);
|
||||
rightArm = new ModelRenderer(this);
|
||||
rightArm.setRotationPoint(10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(rightArm);
|
||||
setRotationAngle(rightArm, -0.6091F, -0.05F, -0.0715F);
|
||||
rightArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, true);
|
||||
rightArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, true);
|
||||
rightArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, true);
|
||||
HeadX = new ModelRenderer(this);
|
||||
HeadX.setRotationPoint(0.0F, -13.0F, 0.0F);
|
||||
UpperBody.addChild(HeadX);
|
||||
setRotationAngle(HeadX, 0.0F, 0.1309F, 0.0F);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
HeadX.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 0.0F, -0.7854F, 0.0F);
|
||||
cube_r2.setTextureOffset(68, 49).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.0F, false);
|
||||
cube_r2.setTextureOffset(68, 64).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.25F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
bone.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.DormantEmberleafMilitaryBotEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class DormantEmberleafMilitaryBotRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(DormantEmberleafMilitaryBotEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelEmberleafMilitaryBotDormant(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/emberleafmilitaryrobot.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.5
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelEmberleafMilitaryBotDormant extends EntityModel<Entity> {
|
||||
private final ModelRenderer LeftLeg;
|
||||
private final ModelRenderer RightLeg;
|
||||
private final ModelRenderer UpperBody;
|
||||
private final ModelRenderer leftArm;
|
||||
private final ModelRenderer rightArm;
|
||||
private final ModelRenderer HeadX;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer bb_main;
|
||||
private final ModelRenderer UpperAbdomine_r1;
|
||||
|
||||
public ModelEmberleafMilitaryBotDormant() {
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
LeftLeg = new ModelRenderer(this);
|
||||
LeftLeg.setRotationPoint(-1.75F, 5.0F, 0.0F);
|
||||
LeftLeg.setTextureOffset(24, 47).addBox(-5.25F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, false);
|
||||
LeftLeg.setTextureOffset(0, 75).addBox(-4.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, false);
|
||||
RightLeg = new ModelRenderer(this);
|
||||
RightLeg.setRotationPoint(1.75F, 5.0F, 0.0F);
|
||||
RightLeg.setTextureOffset(24, 47).addBox(-0.75F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, true);
|
||||
RightLeg.setTextureOffset(0, 75).addBox(0.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, true);
|
||||
UpperBody = new ModelRenderer(this);
|
||||
UpperBody.setRotationPoint(0.0F, -5.25F, 0.0F);
|
||||
setRotationAngle(UpperBody, -0.7854F, 0.0F, 0.0F);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(-11.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(8.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, true);
|
||||
UpperBody.setTextureOffset(68, 38).addBox(4.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(0, 111).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.25F, false);
|
||||
UpperBody.setTextureOffset(0, 0).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(56, 27).addBox(-13.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(44, 0).addBox(-1.5F, -16.5F, -1.5F, 3.0F, 7.0F, 3.0F, 0.0F, false);
|
||||
leftArm = new ModelRenderer(this);
|
||||
leftArm.setRotationPoint(-10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(leftArm);
|
||||
setRotationAngle(leftArm, 0.8727F, 0.0F, 0.0F);
|
||||
leftArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, false);
|
||||
leftArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, false);
|
||||
leftArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, false);
|
||||
rightArm = new ModelRenderer(this);
|
||||
rightArm.setRotationPoint(10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(rightArm);
|
||||
setRotationAngle(rightArm, 0.8727F, 0.0F, 0.0F);
|
||||
rightArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, true);
|
||||
rightArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, true);
|
||||
rightArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, true);
|
||||
HeadX = new ModelRenderer(this);
|
||||
HeadX.setRotationPoint(0.0F, -13.0F, 0.0F);
|
||||
UpperBody.addChild(HeadX);
|
||||
setRotationAngle(HeadX, 0.0F, -0.3491F, 0.0F);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
HeadX.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0F, -0.7854F, 0.0F);
|
||||
cube_r1.setTextureOffset(68, 49).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.0F, false);
|
||||
cube_r1.setTextureOffset(68, 64).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.25F, false);
|
||||
bb_main = new ModelRenderer(this);
|
||||
bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
|
||||
bb_main.setTextureOffset(17, 75).addBox(-4.0F, -27.75F, -2.0F, 8.0F, 6.0F, 4.0F, 0.0F, false);
|
||||
bb_main.setTextureOffset(76, 0).addBox(-2.0F, -21.75F, -2.0F, 4.0F, 5.0F, 4.0F, 0.0F, false);
|
||||
UpperAbdomine_r1 = new ModelRenderer(this);
|
||||
UpperAbdomine_r1.setRotationPoint(0.0F, -30.75F, 0.0F);
|
||||
bb_main.addChild(UpperAbdomine_r1);
|
||||
setRotationAngle(UpperAbdomine_r1, 0.0F, 0.0F, -3.1416F);
|
||||
UpperAbdomine_r1.setTextureOffset(17, 76).addBox(-4.0F, -3.0F, -2.0F, 8.0F, 3.0F, 4.0F, 0.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
LeftLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
UpperBody.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.EmberleafMilitaryBotEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class EmberleafMilitaryBotRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EmberleafMilitaryBotEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelEmberleafMilitaryBot(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/emberleafmilitaryrobotawake.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.5
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelEmberleafMilitaryBot extends EntityModel<Entity> {
|
||||
private final ModelRenderer LeftLeg;
|
||||
private final ModelRenderer RightLeg;
|
||||
private final ModelRenderer UpperBody;
|
||||
private final ModelRenderer leftArm;
|
||||
private final ModelRenderer rightArm;
|
||||
private final ModelRenderer HeadX;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer bb_main;
|
||||
private final ModelRenderer cube_r2;
|
||||
|
||||
public ModelEmberleafMilitaryBot() {
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
LeftLeg = new ModelRenderer(this);
|
||||
LeftLeg.setRotationPoint(-1.75F, 5.0F, 0.0F);
|
||||
LeftLeg.setTextureOffset(24, 47).addBox(-5.25F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, false);
|
||||
LeftLeg.setTextureOffset(0, 75).addBox(-4.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, false);
|
||||
RightLeg = new ModelRenderer(this);
|
||||
RightLeg.setRotationPoint(1.75F, 5.0F, 0.0F);
|
||||
RightLeg.setTextureOffset(24, 47).addBox(-0.75F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, true);
|
||||
RightLeg.setTextureOffset(0, 75).addBox(0.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, true);
|
||||
UpperBody = new ModelRenderer(this);
|
||||
UpperBody.setRotationPoint(0.0F, -5.25F, 0.0F);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(-11.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(8.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, true);
|
||||
UpperBody.setTextureOffset(68, 38).addBox(4.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(0, 111).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.25F, false);
|
||||
UpperBody.setTextureOffset(0, 0).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(56, 27).addBox(-13.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(44, 0).addBox(-1.5F, -16.5F, -1.5F, 3.0F, 7.0F, 3.0F, 0.0F, false);
|
||||
leftArm = new ModelRenderer(this);
|
||||
leftArm.setRotationPoint(-10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(leftArm);
|
||||
leftArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, false);
|
||||
leftArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, false);
|
||||
leftArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, false);
|
||||
rightArm = new ModelRenderer(this);
|
||||
rightArm.setRotationPoint(10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(rightArm);
|
||||
rightArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, true);
|
||||
rightArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, true);
|
||||
rightArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, true);
|
||||
HeadX = new ModelRenderer(this);
|
||||
HeadX.setRotationPoint(0.0F, -13.0F, 0.0F);
|
||||
UpperBody.addChild(HeadX);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
HeadX.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0F, -0.7854F, 0.0F);
|
||||
cube_r1.setTextureOffset(68, 49).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.0F, false);
|
||||
cube_r1.setTextureOffset(68, 64).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.25F, false);
|
||||
bb_main = new ModelRenderer(this);
|
||||
bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
|
||||
bb_main.setTextureOffset(17, 75).addBox(-4.0F, -27.75F, -2.0F, 8.0F, 6.0F, 4.0F, 0.0F, false);
|
||||
bb_main.setTextureOffset(76, 0).addBox(-2.0F, -21.75F, -2.0F, 4.0F, 5.0F, 4.0F, 0.0F, false);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(0.0F, -30.75F, 0.0F);
|
||||
bb_main.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 0.0F, 0.0F, -3.1416F);
|
||||
cube_r2.setTextureOffset(17, 76).addBox(-4.0F, -3.0F, -2.0F, 8.0F, 3.0F, 4.0F, 0.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
LeftLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
UpperBody.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.LeftLeg.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.UpperBody.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.RightLeg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.rightArm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.leftArm.rotateAngleX = MathHelper.cos(f * 0.6662F) * f1;
|
||||
this.HeadX.rotateAngleY = f3 / (180F / (float) Math.PI);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.EmberleafMilitaryRobotLowerHalfEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class EmberleafMilitaryRobotLowerHalfRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EmberleafMilitaryRobotLowerHalfEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelEmberleafMilitaryBotLowerHalf(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/emberleafmilitaryrobotdestroyed.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.5
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelEmberleafMilitaryBotLowerHalf extends EntityModel<Entity> {
|
||||
private final ModelRenderer LeftLeg;
|
||||
private final ModelRenderer RightLeg;
|
||||
private final ModelRenderer UpperHalf;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer cube_r2;
|
||||
private final ModelRenderer Spine;
|
||||
private final ModelRenderer cube_r3;
|
||||
private final ModelRenderer bb_main;
|
||||
|
||||
public ModelEmberleafMilitaryBotLowerHalf() {
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
LeftLeg = new ModelRenderer(this);
|
||||
LeftLeg.setRotationPoint(-1.75F, 5.0F, 0.0F);
|
||||
LeftLeg.setTextureOffset(24, 47).addBox(-5.25F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, false);
|
||||
LeftLeg.setTextureOffset(0, 75).addBox(-4.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, false);
|
||||
RightLeg = new ModelRenderer(this);
|
||||
RightLeg.setRotationPoint(1.75F, 5.0F, 0.0F);
|
||||
RightLeg.setTextureOffset(24, 47).addBox(-0.75F, -2.75F, -3.0F, 6.0F, 22.0F, 6.0F, -0.25F, true);
|
||||
RightLeg.setTextureOffset(0, 75).addBox(0.25F, -1.75F, -2.0F, 4.0F, 21.0F, 4.0F, 0.25F, true);
|
||||
UpperHalf = new ModelRenderer(this);
|
||||
UpperHalf.setRotationPoint(0.025F, 2.2F, 2.025F);
|
||||
setRotationAngle(UpperHalf, 0.0F, 0.0F, 0.0873F);
|
||||
UpperHalf.setTextureOffset(61, 14).addBox(-2.025F, -16.2F, -2.025F, 4.0F, 9.0F, 0.0F, 0.0F, false);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, -5.6F, -4.55F);
|
||||
UpperHalf.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.2182F, 0.0F, -3.1416F);
|
||||
cube_r1.setTextureOffset(17, 76).addBox(-4.0F, 0.0F, 0.0F, 8.0F, 3.0F, 4.0F, 0.0F, false);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(-0.025F, 0.05F, -0.025F);
|
||||
UpperHalf.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 0.0873F, 0.0F, 0.0F);
|
||||
cube_r2.setTextureOffset(17, 75).addBox(-4.0F, -6.0F, -4.0F, 8.0F, 6.0F, 4.0F, 0.0F, false);
|
||||
Spine = new ModelRenderer(this);
|
||||
Spine.setRotationPoint(-0.025F, -15.7F, -1.9375F);
|
||||
UpperHalf.addChild(Spine);
|
||||
setRotationAngle(Spine, 0.0F, 0.0F, 0.1309F);
|
||||
cube_r3 = new ModelRenderer(this);
|
||||
cube_r3.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
Spine.addChild(cube_r3);
|
||||
setRotationAngle(cube_r3, 0.0F, 0.0F, 2.0071F);
|
||||
cube_r3.setTextureOffset(61, 14).addBox(-2.0305F, -7.8824F, 0.0F, 4.0F, 9.0F, 0.0F, 0.0F, false);
|
||||
bb_main = new ModelRenderer(this);
|
||||
bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
|
||||
bb_main.setTextureOffset(76, 0).addBox(-2.0F, -21.75F, -2.0F, 4.0F, 5.0F, 4.0F, 0.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
LeftLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
UpperHalf.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.LeftLeg.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightLeg.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.Spine.rotateAngleZ = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.EmberleafMilitaryRobotUpperHalfEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class EmberleafMilitaryRobotUpperHalfRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EmberleafMilitaryRobotUpperHalfEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelEmberleafMilitaryBotUpperHalf(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/emberleafmilitaryrobotdestroyed.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.5
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelEmberleafMilitaryBotUpperHalf extends EntityModel<Entity> {
|
||||
private final ModelRenderer UpperBody;
|
||||
private final ModelRenderer leftArm;
|
||||
private final ModelRenderer rightArm;
|
||||
private final ModelRenderer HeadX;
|
||||
private final ModelRenderer cube_r1;
|
||||
|
||||
public ModelEmberleafMilitaryBotUpperHalf() {
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
UpperBody = new ModelRenderer(this);
|
||||
UpperBody.setRotationPoint(0.0F, 9.75F, 0.0F);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(-11.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(48, 90).addBox(8.5F, -7.6F, -2.0F, 3.0F, 4.0F, 4.0F, 0.0F, true);
|
||||
UpperBody.setTextureOffset(68, 38).addBox(4.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(0, 111).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.25F, false);
|
||||
UpperBody.setTextureOffset(0, 0).addBox(-8.0F, -9.5F, -3.0F, 16.0F, 11.0F, 6.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(56, 27).addBox(-13.0F, -10.5F, -4.0F, 9.0F, 3.0F, 8.0F, 0.0F, false);
|
||||
UpperBody.setTextureOffset(44, 0).addBox(-1.5F, -16.5F, -1.5F, 3.0F, 7.0F, 3.0F, 0.0F, false);
|
||||
leftArm = new ModelRenderer(this);
|
||||
leftArm.setRotationPoint(-10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(leftArm);
|
||||
leftArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, false);
|
||||
leftArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, false);
|
||||
leftArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, false);
|
||||
rightArm = new ModelRenderer(this);
|
||||
rightArm.setRotationPoint(10.0F, -7.5F, 0.0F);
|
||||
UpperBody.addChild(rightArm);
|
||||
rightArm.setTextureOffset(28, 20).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, 0.0F, true);
|
||||
rightArm.setTextureOffset(48, 47).addBox(-2.0F, 0.0F, -3.0F, 4.0F, 21.0F, 6.0F, -0.24F, true);
|
||||
rightArm.setTextureOffset(0, 17).addBox(-3.0F, 0.0F, -4.0F, 6.0F, 22.0F, 8.0F, -0.25F, true);
|
||||
HeadX = new ModelRenderer(this);
|
||||
HeadX.setRotationPoint(0.0F, -13.0F, 0.0F);
|
||||
UpperBody.addChild(HeadX);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
HeadX.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0F, -0.7854F, 0.0F);
|
||||
cube_r1.setTextureOffset(68, 49).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.0F, false);
|
||||
cube_r1.setTextureOffset(68, 64).addBox(-3.5F, -6.5F, -3.5F, 7.0F, 8.0F, 7.0F, 0.25F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
UpperBody.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.rightArm.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.leftArm.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.HeadX.rotateAngleY = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.FluffaloEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class FluffaloRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(FluffaloEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelFluffalo(), 1.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/fluffalo.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 5.0.3
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelFluffalo extends EntityModel<Entity> {
|
||||
private final ModelRenderer Body;
|
||||
private final ModelRenderer Tail2;
|
||||
private final ModelRenderer Tail;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer Head;
|
||||
private final ModelRenderer horn;
|
||||
private final ModelRenderer cube_r2;
|
||||
private final ModelRenderer LeftFoot1;
|
||||
private final ModelRenderer RightFoot1;
|
||||
private final ModelRenderer LeftFoot2;
|
||||
private final ModelRenderer RightFoot2;
|
||||
private final ModelRenderer LeftFoot3;
|
||||
private final ModelRenderer RightFoot3;
|
||||
|
||||
public ModelFluffalo() {
|
||||
textureWidth = 256;
|
||||
textureHeight = 256;
|
||||
Body = new ModelRenderer(this);
|
||||
Body.setRotationPoint(-0.5F, 11.0F, -3.25F);
|
||||
Body.setTextureOffset(0, 0).addBox(-11.5F, -15.0F, -14.75F, 24.0F, 21.0F, 36.0F, 0.0F, false);
|
||||
Body.setTextureOffset(0, 114).addBox(-11.5F, 6.0F, -14.75F, 24.0F, 7.0F, 36.0F, 0.0F, false);
|
||||
Body.setTextureOffset(120, 0).addBox(0.5F, -22.0F, -21.75F, 0.0F, 16.0F, 47.0F, 0.0F, false);
|
||||
Tail2 = new ModelRenderer(this);
|
||||
Tail2.setRotationPoint(0.5F, -7.0F, 21.75F);
|
||||
Body.addChild(Tail2);
|
||||
Tail = new ModelRenderer(this);
|
||||
Tail.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
Tail2.addChild(Tail);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
Tail.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0873F, 0.0F, 0.0F);
|
||||
cube_r1.setTextureOffset(148, 131).addBox(-3.0F, -2.0F, 0.0F, 6.0F, 21.0F, 0.0F, 0.0F, false);
|
||||
Head = new ModelRenderer(this);
|
||||
Head.setRotationPoint(0.0F, -2.0F, -15.0F);
|
||||
Body.addChild(Head);
|
||||
Head.setTextureOffset(120, 83).addBox(-5.5F, -6.0F, -8.75F, 11.0F, 11.0F, 9.0F, 0.25F, false);
|
||||
Head.setTextureOffset(148, 152).addBox(-3.5F, -1.0F, -10.75F, 7.0F, 6.0F, 2.0F, 0.0F, false);
|
||||
Head.setTextureOffset(120, 103).addBox(-5.5F, 5.5F, -8.75F, 11.0F, 8.0F, 9.0F, 0.25F, false);
|
||||
Head.setTextureOffset(120, 63).addBox(-5.5F, -6.0F, -8.75F, 11.0F, 11.0F, 9.0F, 0.0F, false);
|
||||
horn = new ModelRenderer(this);
|
||||
horn.setRotationPoint(0.0F, 2.0F, -11.0F);
|
||||
Head.addChild(horn);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
horn.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, -0.4363F, 0.0F, 0.0F);
|
||||
cube_r2.setTextureOffset(120, 120).addBox(-8.5F, -2.0F, 0.0F, 17.0F, 11.0F, 0.0F, 0.0F, false);
|
||||
LeftFoot1 = new ModelRenderer(this);
|
||||
LeftFoot1.setRotationPoint(7.0F, 17.0F, -12.0F);
|
||||
LeftFoot1.setTextureOffset(120, 131).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, false);
|
||||
LeftFoot1.setTextureOffset(120, 145).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, false);
|
||||
RightFoot1 = new ModelRenderer(this);
|
||||
RightFoot1.setRotationPoint(-7.0F, 17.0F, -12.0F);
|
||||
RightFoot1.setTextureOffset(120, 131).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, true);
|
||||
RightFoot1.setTextureOffset(120, 145).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, true);
|
||||
LeftFoot2 = new ModelRenderer(this);
|
||||
LeftFoot2.setRotationPoint(7.0F, 17.0F, 0.0F);
|
||||
LeftFoot2.setTextureOffset(120, 131).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, false);
|
||||
LeftFoot2.setTextureOffset(120, 145).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, false);
|
||||
RightFoot2 = new ModelRenderer(this);
|
||||
RightFoot2.setRotationPoint(-7.0F, 17.0F, 0.0F);
|
||||
RightFoot2.setTextureOffset(120, 131).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, true);
|
||||
RightFoot2.setTextureOffset(120, 145).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, true);
|
||||
LeftFoot3 = new ModelRenderer(this);
|
||||
LeftFoot3.setRotationPoint(7.0F, 17.0F, 11.0F);
|
||||
LeftFoot3.setTextureOffset(120, 131).addBox(-4.0F, 0.0F, -3.0F, 7.0F, 7.0F, 7.0F, 0.0F, false);
|
||||
LeftFoot3.setTextureOffset(120, 145).addBox(-4.0F, 0.0F, -3.0F, 7.0F, 7.0F, 7.0F, 0.25F, false);
|
||||
RightFoot3 = new ModelRenderer(this);
|
||||
RightFoot3.setRotationPoint(-7.0F, 17.0F, 12.0F);
|
||||
RightFoot3.setTextureOffset(120, 131).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, true);
|
||||
RightFoot3.setTextureOffset(120, 145).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftFoot1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightFoot1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftFoot2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightFoot2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftFoot3.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightFoot3.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
|
||||
this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.Tail2.rotateAngleZ = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.RightFoot3.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.RightFoot2.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.horn.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.Tail.rotateAngleZ = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.Body.rotateAngleZ = MathHelper.cos(f * 0.6662F) * f1;
|
||||
this.LeftFoot3.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightFoot1.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftFoot2.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftFoot1.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.procedures.FluffaloShavedEntityShakingConditionProcedure;
|
||||
import studio.halbear.hem.entity.FluffaloShavedEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class FluffaloShavedRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(FluffaloShavedEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelFluffaloShaved(), 1.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/fluffalo.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean func_230495_a_(LivingEntity _ent) {
|
||||
Entity entity = _ent;
|
||||
World world = entity.world;
|
||||
double x = entity.getPosX();
|
||||
double y = entity.getPosY();
|
||||
double z = entity.getPosZ();
|
||||
return FluffaloShavedEntityShakingConditionProcedure.executeProcedure(Collections.emptyMap());
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 5.0.3
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelFluffaloShaved extends EntityModel<Entity> {
|
||||
private final ModelRenderer Body;
|
||||
private final ModelRenderer Tail2;
|
||||
private final ModelRenderer Tail;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer Head;
|
||||
private final ModelRenderer horn;
|
||||
private final ModelRenderer cube_r2;
|
||||
private final ModelRenderer LeftFoot1;
|
||||
private final ModelRenderer RightFoot1;
|
||||
private final ModelRenderer LeftFoot2;
|
||||
private final ModelRenderer RightFoot2;
|
||||
private final ModelRenderer LeftFoot3;
|
||||
private final ModelRenderer RightFoot3;
|
||||
|
||||
public ModelFluffaloShaved() {
|
||||
textureWidth = 256;
|
||||
textureHeight = 256;
|
||||
Body = new ModelRenderer(this);
|
||||
Body.setRotationPoint(-0.5F, 12.0F, -3.25F);
|
||||
Body.setTextureOffset(0, 199).addBox(-11.5F, -14.0F, -15.75F, 24.0F, 21.0F, 36.0F, -0.5F, false);
|
||||
Tail2 = new ModelRenderer(this);
|
||||
Tail2.setRotationPoint(0.5F, -7.0F, 21.75F);
|
||||
Body.addChild(Tail2);
|
||||
Tail = new ModelRenderer(this);
|
||||
Tail.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
Tail2.addChild(Tail);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 0.0F, -2.0F);
|
||||
Tail.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0873F, 0.0F, 0.0F);
|
||||
cube_r1.setTextureOffset(148, 131).addBox(-3.0F, -2.0F, 0.0F, 6.0F, 21.0F, 0.0F, 0.0F, false);
|
||||
Head = new ModelRenderer(this);
|
||||
Head.setRotationPoint(0.0F, -2.0F, -15.0F);
|
||||
Body.addChild(Head);
|
||||
Head.setTextureOffset(148, 160).addBox(-3.5F, -1.0F, -10.75F, 7.0F, 6.0F, 2.0F, 0.0F, false);
|
||||
Head.setTextureOffset(120, 63).addBox(-5.5F, -6.0F, -8.75F, 11.0F, 11.0F, 9.0F, 0.0F, false);
|
||||
horn = new ModelRenderer(this);
|
||||
horn.setRotationPoint(0.0F, 2.0F, -11.0F);
|
||||
Head.addChild(horn);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
horn.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, -0.4363F, 0.0F, 0.0F);
|
||||
cube_r2.setTextureOffset(120, 120).addBox(-8.5F, -2.0F, 0.0F, 17.0F, 11.0F, 0.0F, 0.0F, false);
|
||||
LeftFoot1 = new ModelRenderer(this);
|
||||
LeftFoot1.setRotationPoint(7.0F, 17.0F, -12.0F);
|
||||
LeftFoot1.setTextureOffset(120, 131).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, false);
|
||||
LeftFoot1.setTextureOffset(120, 145).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, false);
|
||||
RightFoot1 = new ModelRenderer(this);
|
||||
RightFoot1.setRotationPoint(-7.0F, 17.0F, -12.0F);
|
||||
RightFoot1.setTextureOffset(120, 131).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, true);
|
||||
RightFoot1.setTextureOffset(120, 145).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, true);
|
||||
LeftFoot2 = new ModelRenderer(this);
|
||||
LeftFoot2.setRotationPoint(7.0F, 17.0F, 0.0F);
|
||||
LeftFoot2.setTextureOffset(120, 131).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, false);
|
||||
LeftFoot2.setTextureOffset(120, 145).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, false);
|
||||
RightFoot2 = new ModelRenderer(this);
|
||||
RightFoot2.setRotationPoint(-7.0F, 17.0F, 0.0F);
|
||||
RightFoot2.setTextureOffset(120, 131).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, true);
|
||||
RightFoot2.setTextureOffset(120, 145).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, true);
|
||||
LeftFoot3 = new ModelRenderer(this);
|
||||
LeftFoot3.setRotationPoint(7.0F, 17.0F, 11.0F);
|
||||
LeftFoot3.setTextureOffset(120, 131).addBox(-4.0F, 0.0F, -3.0F, 7.0F, 7.0F, 7.0F, 0.0F, false);
|
||||
LeftFoot3.setTextureOffset(120, 145).addBox(-4.0F, 0.0F, -3.0F, 7.0F, 7.0F, 7.0F, 0.25F, false);
|
||||
RightFoot3 = new ModelRenderer(this);
|
||||
RightFoot3.setRotationPoint(-7.0F, 17.0F, 12.0F);
|
||||
RightFoot3.setTextureOffset(120, 131).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.0F, true);
|
||||
RightFoot3.setTextureOffset(120, 145).addBox(-3.0F, 0.0F, -4.0F, 7.0F, 7.0F, 7.0F, 0.25F, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftFoot1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightFoot1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftFoot2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightFoot2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftFoot3.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightFoot3.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
|
||||
this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.Tail2.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightFoot3.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.RightFoot2.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.horn.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.Tail.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.Body.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftFoot3.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightFoot1.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftFoot2.rotateAngleX = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftFoot1.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.GiantButterflyEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GiantButterflyRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(GiantButterflyEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelGiantButterfly(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/giantbutterfly.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.4
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelGiantButterfly extends EntityModel<Entity> {
|
||||
private final ModelRenderer Head;
|
||||
private final ModelRenderer antenna2;
|
||||
private final ModelRenderer antenna_r1;
|
||||
private final ModelRenderer antenna;
|
||||
private final ModelRenderer antenna_r2;
|
||||
private final ModelRenderer Body;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer cube_r2;
|
||||
private final ModelRenderer RightLowerWingOuter1;
|
||||
private final ModelRenderer RightLowerWing;
|
||||
private final ModelRenderer RightLowerWing_r1;
|
||||
private final ModelRenderer RightUpperWingOuter1;
|
||||
private final ModelRenderer RightUpperWIng;
|
||||
private final ModelRenderer RightUpperWIng_r1;
|
||||
private final ModelRenderer LeftUpperWIngouter1;
|
||||
private final ModelRenderer LeftUpperWIng;
|
||||
private final ModelRenderer LeftUpperWIng_r1;
|
||||
private final ModelRenderer LeftLowerWIngouter1;
|
||||
private final ModelRenderer LeftLowerWing;
|
||||
private final ModelRenderer LeftLowerWing_r1;
|
||||
private final ModelRenderer RightLegs;
|
||||
private final ModelRenderer cube_r3;
|
||||
private final ModelRenderer LeftLegs;
|
||||
private final ModelRenderer cube_r4;
|
||||
|
||||
public ModelGiantButterfly() {
|
||||
textureWidth = 256;
|
||||
textureHeight = 256;
|
||||
Head = new ModelRenderer(this);
|
||||
Head.setRotationPoint(0.0F, 8.0F, -5.0F);
|
||||
Head.setTextureOffset(138, 135).addBox(-4.0F, -4.0F, -9.0F, 8.0F, 9.0F, 9.0F, 0.0F, false);
|
||||
Head.setTextureOffset(0, 142).addBox(0.0F, -2.0F, -16.0F, 0.0F, 18.0F, 10.0F, 0.0F, false);
|
||||
antenna2 = new ModelRenderer(this);
|
||||
antenna2.setRotationPoint(2.0F, -4.0F, -4.0F);
|
||||
Head.addChild(antenna2);
|
||||
antenna_r1 = new ModelRenderer(this);
|
||||
antenna_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
antenna2.addChild(antenna_r1);
|
||||
setRotationAngle(antenna_r1, 1.5708F, 1.1345F, 1.9635F);
|
||||
antenna_r1.setTextureOffset(91, 135).addBox(0.0F, -18.0F, -3.0F, 0.0F, 22.0F, 12.0F, 0.0F, false);
|
||||
antenna = new ModelRenderer(this);
|
||||
antenna.setRotationPoint(-2.0F, -4.0F, -4.0F);
|
||||
Head.addChild(antenna);
|
||||
antenna_r2 = new ModelRenderer(this);
|
||||
antenna_r2.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
antenna.addChild(antenna_r2);
|
||||
setRotationAngle(antenna_r2, 1.5708F, -1.1345F, -1.9635F);
|
||||
antenna_r2.setTextureOffset(114, 135).addBox(0.0F, -18.0F, -3.0F, 0.0F, 22.0F, 12.0F, 0.0F, false);
|
||||
Body = new ModelRenderer(this);
|
||||
Body.setRotationPoint(0.0F, 8.0F, -5.0F);
|
||||
setRotationAngle(Body, -0.3927F, 0.0F, 0.0F);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 19.363F, 26.4211F);
|
||||
Body.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.7854F, 0.0F, 0.0F);
|
||||
cube_r1.setTextureOffset(54, 135).addBox(-4.0F, -21.0F, -5.0F, 8.0F, 21.0F, 10.0F, 0.0F, false);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(0.0F, 4.563F, 14.5211F);
|
||||
Body.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 1.3963F, 0.0F, 0.0F);
|
||||
cube_r2.setTextureOffset(0, 111).addBox(-6.0F, -16.0F, -9.0F, 12.0F, 16.0F, 15.0F, 0.0F, false);
|
||||
RightLowerWingOuter1 = new ModelRenderer(this);
|
||||
RightLowerWingOuter1.setRotationPoint(-6.05F, -2.037F, 10.7711F);
|
||||
Body.addChild(RightLowerWingOuter1);
|
||||
RightLowerWing = new ModelRenderer(this);
|
||||
RightLowerWing.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightLowerWingOuter1.addChild(RightLowerWing);
|
||||
RightLowerWing_r1 = new ModelRenderer(this);
|
||||
RightLowerWing_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightLowerWing.addChild(RightLowerWing_r1);
|
||||
setRotationAngle(RightLowerWing_r1, 1.4319F, -0.2446F, -0.7479F);
|
||||
RightLowerWing_r1.setTextureOffset(97, 3).addBox(-0.1134F, -15.1127F, -2.2365F, 0.0F, 59.0F, 46.0F, 0.0F, true);
|
||||
RightUpperWingOuter1 = new ModelRenderer(this);
|
||||
RightUpperWingOuter1.setRotationPoint(-6.0F, -2.637F, 8.5211F);
|
||||
Body.addChild(RightUpperWingOuter1);
|
||||
RightUpperWIng = new ModelRenderer(this);
|
||||
RightUpperWIng.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightUpperWingOuter1.addChild(RightUpperWIng);
|
||||
RightUpperWIng_r1 = new ModelRenderer(this);
|
||||
RightUpperWIng_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightUpperWIng.addChild(RightUpperWIng_r1);
|
||||
setRotationAngle(RightUpperWIng_r1, 1.44F, -0.0768F, -0.7941F);
|
||||
RightUpperWIng_r1.setTextureOffset(2, 2).addBox(0.0F, -23.8409F, -2.0487F, 0.0F, 63.0F, 46.0F, 0.0F, true);
|
||||
LeftUpperWIngouter1 = new ModelRenderer(this);
|
||||
LeftUpperWIngouter1.setRotationPoint(6.0F, -2.637F, 8.5211F);
|
||||
Body.addChild(LeftUpperWIngouter1);
|
||||
LeftUpperWIng = new ModelRenderer(this);
|
||||
LeftUpperWIng.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftUpperWIngouter1.addChild(LeftUpperWIng);
|
||||
LeftUpperWIng_r1 = new ModelRenderer(this);
|
||||
LeftUpperWIng_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftUpperWIng.addChild(LeftUpperWIng_r1);
|
||||
setRotationAngle(LeftUpperWIng_r1, 1.44F, 0.0768F, 0.7941F);
|
||||
LeftUpperWIng_r1.setTextureOffset(2, 2).addBox(0.0F, -23.8409F, -2.0487F, 0.0F, 63.0F, 46.0F, 0.0F, false);
|
||||
LeftLowerWIngouter1 = new ModelRenderer(this);
|
||||
LeftLowerWIngouter1.setRotationPoint(6.0F, -2.0F, 10.0F);
|
||||
Body.addChild(LeftLowerWIngouter1);
|
||||
LeftLowerWing = new ModelRenderer(this);
|
||||
LeftLowerWing.setRotationPoint(0.05F, -0.037F, 0.7711F);
|
||||
LeftLowerWIngouter1.addChild(LeftLowerWing);
|
||||
LeftLowerWing_r1 = new ModelRenderer(this);
|
||||
LeftLowerWing_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftLowerWing.addChild(LeftLowerWing_r1);
|
||||
setRotationAngle(LeftLowerWing_r1, 1.4319F, 0.2446F, 0.7479F);
|
||||
LeftLowerWing_r1.setTextureOffset(97, 3).addBox(0.1134F, -15.1127F, -2.2365F, 0.0F, 59.0F, 46.0F, 0.0F, false);
|
||||
RightLegs = new ModelRenderer(this);
|
||||
RightLegs.setRotationPoint(-6.0F, 7.063F, 5.5211F);
|
||||
Body.addChild(RightLegs);
|
||||
cube_r3 = new ModelRenderer(this);
|
||||
cube_r3.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightLegs.addChild(cube_r3);
|
||||
setRotationAngle(cube_r3, 1.4829F, -0.151F, -1.0405F);
|
||||
cube_r3.setTextureOffset(98, 111).addBox(-22.0F, -11.5709F, 0.0248F, 22.0F, 24.0F, 0.0F, 0.0F, false);
|
||||
LeftLegs = new ModelRenderer(this);
|
||||
LeftLegs.setRotationPoint(6.0F, 7.063F, 5.5211F);
|
||||
Body.addChild(LeftLegs);
|
||||
cube_r4 = new ModelRenderer(this);
|
||||
cube_r4.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftLegs.addChild(cube_r4);
|
||||
setRotationAngle(cube_r4, 1.4829F, 0.151F, 1.0405F);
|
||||
cube_r4.setTextureOffset(98, 111).addBox(0.0F, -11.5709F, 0.0248F, 22.0F, 24.0F, 0.0F, 0.0F, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
Head.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.antenna.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.LeftLowerWIngouter1.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightUpperWIng.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftLowerWing.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
|
||||
this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.RightLowerWing.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftUpperWIng_r1.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.LeftUpperWIngouter1.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightLegs.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.LeftUpperWIng.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightLowerWingOuter1.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.RightUpperWingOuter1.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftLegs.rotateAngleY = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.RightUpperWIng_r1.rotateAngleY = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.antenna2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.Body.rotateAngleX = MathHelper.cos(f * 0.6662F) * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.GiantButterflyWalkingEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GiantButterflyWalkingRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(GiantButterflyWalkingEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelGiantButterflyWalking(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/giantbutterfly.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.4
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelGiantButterflyWalking extends EntityModel<Entity> {
|
||||
private final ModelRenderer Head;
|
||||
private final ModelRenderer antenna2;
|
||||
private final ModelRenderer antenna_r1;
|
||||
private final ModelRenderer antenna;
|
||||
private final ModelRenderer antenna_r2;
|
||||
private final ModelRenderer Body;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer LeftUpperWIngouter1;
|
||||
private final ModelRenderer LeftUpperWIng;
|
||||
private final ModelRenderer LeftUpperWIng_r1;
|
||||
private final ModelRenderer RightUpperWIngouter1;
|
||||
private final ModelRenderer RightUpperWIng;
|
||||
private final ModelRenderer RightUpperWIng_r1;
|
||||
private final ModelRenderer LeftLowerWIngouter1;
|
||||
private final ModelRenderer LeftLowerWing;
|
||||
private final ModelRenderer LeftLowerWing_r1;
|
||||
private final ModelRenderer RightLowerWIngouter1;
|
||||
private final ModelRenderer RightLowerWing;
|
||||
private final ModelRenderer RightLowerWing_r1;
|
||||
private final ModelRenderer RightLegs;
|
||||
private final ModelRenderer cube_r2;
|
||||
private final ModelRenderer cube_r3;
|
||||
private final ModelRenderer LeftLegs;
|
||||
private final ModelRenderer cube_r4;
|
||||
private final ModelRenderer cube_r5;
|
||||
private final ModelRenderer RightLegs2;
|
||||
private final ModelRenderer cube_r6;
|
||||
private final ModelRenderer LeftLegs2;
|
||||
private final ModelRenderer cube_r7;
|
||||
private final ModelRenderer butt;
|
||||
private final ModelRenderer cube_r8;
|
||||
|
||||
public ModelGiantButterflyWalking() {
|
||||
textureWidth = 256;
|
||||
textureHeight = 256;
|
||||
Head = new ModelRenderer(this);
|
||||
Head.setRotationPoint(0.0F, 8.0F, -5.0F);
|
||||
Head.setTextureOffset(138, 135).addBox(-4.0F, -4.0F, -9.0F, 8.0F, 9.0F, 9.0F, 0.0F, false);
|
||||
Head.setTextureOffset(0, 142).addBox(0.0F, -2.0F, -16.0F, 0.0F, 18.0F, 10.0F, 0.0F, false);
|
||||
antenna2 = new ModelRenderer(this);
|
||||
antenna2.setRotationPoint(2.0F, -4.0F, -4.0F);
|
||||
Head.addChild(antenna2);
|
||||
antenna_r1 = new ModelRenderer(this);
|
||||
antenna_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
antenna2.addChild(antenna_r1);
|
||||
setRotationAngle(antenna_r1, 1.5708F, 1.1345F, 1.9635F);
|
||||
antenna_r1.setTextureOffset(91, 135).addBox(0.0F, -18.0F, -3.0F, 0.0F, 22.0F, 12.0F, 0.0F, false);
|
||||
antenna = new ModelRenderer(this);
|
||||
antenna.setRotationPoint(-2.0F, -4.0F, -4.0F);
|
||||
Head.addChild(antenna);
|
||||
antenna_r2 = new ModelRenderer(this);
|
||||
antenna_r2.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
antenna.addChild(antenna_r2);
|
||||
setRotationAngle(antenna_r2, 1.5708F, -1.1345F, -1.9635F);
|
||||
antenna_r2.setTextureOffset(114, 135).addBox(0.0F, -18.0F, -3.0F, 0.0F, 22.0F, 12.0F, 0.0F, false);
|
||||
Body = new ModelRenderer(this);
|
||||
Body.setRotationPoint(0.0F, 8.0F, -5.0F);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 4.563F, 14.5211F);
|
||||
Body.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 1.3963F, 0.0F, 0.0F);
|
||||
cube_r1.setTextureOffset(0, 111).addBox(-6.0F, -16.0F, -9.0F, 12.0F, 16.0F, 15.0F, 0.0F, false);
|
||||
LeftUpperWIngouter1 = new ModelRenderer(this);
|
||||
LeftUpperWIngouter1.setRotationPoint(6.0F, -2.637F, 8.5211F);
|
||||
Body.addChild(LeftUpperWIngouter1);
|
||||
setRotationAngle(LeftUpperWIngouter1, 0.0F, 0.0F, -0.6109F);
|
||||
LeftUpperWIng = new ModelRenderer(this);
|
||||
LeftUpperWIng.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftUpperWIngouter1.addChild(LeftUpperWIng);
|
||||
LeftUpperWIng_r1 = new ModelRenderer(this);
|
||||
LeftUpperWIng_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftUpperWIng.addChild(LeftUpperWIng_r1);
|
||||
setRotationAngle(LeftUpperWIng_r1, 1.44F, 0.0768F, 0.7941F);
|
||||
LeftUpperWIng_r1.setTextureOffset(2, 2).addBox(0.0F, -23.8409F, -2.0487F, 0.0F, 63.0F, 46.0F, 0.0F, false);
|
||||
RightUpperWIngouter1 = new ModelRenderer(this);
|
||||
RightUpperWIngouter1.setRotationPoint(-6.0F, -2.637F, 8.5211F);
|
||||
Body.addChild(RightUpperWIngouter1);
|
||||
setRotationAngle(RightUpperWIngouter1, 0.0F, 0.0F, 0.6109F);
|
||||
RightUpperWIng = new ModelRenderer(this);
|
||||
RightUpperWIng.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightUpperWIngouter1.addChild(RightUpperWIng);
|
||||
RightUpperWIng_r1 = new ModelRenderer(this);
|
||||
RightUpperWIng_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightUpperWIng.addChild(RightUpperWIng_r1);
|
||||
setRotationAngle(RightUpperWIng_r1, 1.44F, -0.0768F, -0.7941F);
|
||||
RightUpperWIng_r1.setTextureOffset(2, 2).addBox(0.0F, -23.8409F, -2.0487F, 0.0F, 63.0F, 46.0F, 0.0F, true);
|
||||
LeftLowerWIngouter1 = new ModelRenderer(this);
|
||||
LeftLowerWIngouter1.setRotationPoint(6.0F, -2.0F, 8.0F);
|
||||
Body.addChild(LeftLowerWIngouter1);
|
||||
setRotationAngle(LeftLowerWIngouter1, 0.0F, -0.2618F, -0.7854F);
|
||||
LeftLowerWing = new ModelRenderer(this);
|
||||
LeftLowerWing.setRotationPoint(0.05F, -0.037F, 2.7711F);
|
||||
LeftLowerWIngouter1.addChild(LeftLowerWing);
|
||||
LeftLowerWing_r1 = new ModelRenderer(this);
|
||||
LeftLowerWing_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftLowerWing.addChild(LeftLowerWing_r1);
|
||||
setRotationAngle(LeftLowerWing_r1, 1.4319F, 0.2446F, 0.7479F);
|
||||
LeftLowerWing_r1.setTextureOffset(97, 3).addBox(0.1134F, -15.1127F, -2.2365F, 0.0F, 59.0F, 46.0F, 0.0F, false);
|
||||
RightLowerWIngouter1 = new ModelRenderer(this);
|
||||
RightLowerWIngouter1.setRotationPoint(-6.0F, -2.0F, 8.0F);
|
||||
Body.addChild(RightLowerWIngouter1);
|
||||
setRotationAngle(RightLowerWIngouter1, 0.0F, 0.2618F, 0.7854F);
|
||||
RightLowerWing = new ModelRenderer(this);
|
||||
RightLowerWing.setRotationPoint(-0.05F, -0.037F, 2.7711F);
|
||||
RightLowerWIngouter1.addChild(RightLowerWing);
|
||||
RightLowerWing_r1 = new ModelRenderer(this);
|
||||
RightLowerWing_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightLowerWing.addChild(RightLowerWing_r1);
|
||||
setRotationAngle(RightLowerWing_r1, 1.4319F, -0.2446F, -0.7479F);
|
||||
RightLowerWing_r1.setTextureOffset(97, 3).addBox(-0.1134F, -15.1127F, -2.2365F, 0.0F, 59.0F, 46.0F, 0.0F, true);
|
||||
RightLegs = new ModelRenderer(this);
|
||||
RightLegs.setRotationPoint(-6.0F, 3.063F, 7.5211F);
|
||||
Body.addChild(RightLegs);
|
||||
setRotationAngle(RightLegs, 0.0F, 0.0F, 0.3491F);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(0.0F, -0.063F, -3.5211F);
|
||||
RightLegs.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 1.5708F, 0.0873F, -1.0472F);
|
||||
cube_r2.setTextureOffset(139, 237).addBox(-22.0F, 3.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, false);
|
||||
cube_r3 = new ModelRenderer(this);
|
||||
cube_r3.setRotationPoint(0.0F, -0.063F, -2.0211F);
|
||||
RightLegs.addChild(cube_r3);
|
||||
setRotationAngle(cube_r3, 1.5708F, -0.0873F, -1.0472F);
|
||||
cube_r3.setTextureOffset(141, 187).addBox(-22.0F, -9.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, false);
|
||||
LeftLegs = new ModelRenderer(this);
|
||||
LeftLegs.setRotationPoint(6.0F, 3.063F, 7.5211F);
|
||||
Body.addChild(LeftLegs);
|
||||
setRotationAngle(LeftLegs, 0.0F, 0.0F, -0.3491F);
|
||||
cube_r4 = new ModelRenderer(this);
|
||||
cube_r4.setRotationPoint(0.0F, -0.063F, -3.5211F);
|
||||
LeftLegs.addChild(cube_r4);
|
||||
setRotationAngle(cube_r4, 1.5708F, -0.0873F, 1.0472F);
|
||||
cube_r4.setTextureOffset(139, 237).addBox(0.0F, 3.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, true);
|
||||
cube_r5 = new ModelRenderer(this);
|
||||
cube_r5.setRotationPoint(0.0F, -0.063F, -2.0211F);
|
||||
LeftLegs.addChild(cube_r5);
|
||||
setRotationAngle(cube_r5, 1.5708F, 0.0873F, 1.0472F);
|
||||
cube_r5.setTextureOffset(141, 187).addBox(0.0F, -9.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, true);
|
||||
RightLegs2 = new ModelRenderer(this);
|
||||
RightLegs2.setRotationPoint(-6.0F, 3.063F, 5.5211F);
|
||||
Body.addChild(RightLegs2);
|
||||
setRotationAngle(RightLegs2, 0.0F, 0.0F, 0.3491F);
|
||||
cube_r6 = new ModelRenderer(this);
|
||||
cube_r6.setRotationPoint(0.0F, -0.063F, 0.4789F);
|
||||
RightLegs2.addChild(cube_r6);
|
||||
setRotationAngle(cube_r6, 1.4835F, 0.0F, -1.0472F);
|
||||
cube_r6.setTextureOffset(139, 218).addBox(-22.0F, -4.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, false);
|
||||
LeftLegs2 = new ModelRenderer(this);
|
||||
LeftLegs2.setRotationPoint(6.0F, 3.063F, 5.5211F);
|
||||
Body.addChild(LeftLegs2);
|
||||
setRotationAngle(LeftLegs2, 0.0F, 0.0F, -0.3491F);
|
||||
cube_r7 = new ModelRenderer(this);
|
||||
cube_r7.setRotationPoint(0.0F, -0.063F, 0.4789F);
|
||||
LeftLegs2.addChild(cube_r7);
|
||||
setRotationAngle(cube_r7, 1.4835F, 0.0F, 1.0472F);
|
||||
cube_r7.setTextureOffset(139, 218).addBox(0.0F, -4.0F, 0.0F, 22.0F, 10.0F, 0.0F, 0.0F, true);
|
||||
butt = new ModelRenderer(this);
|
||||
butt.setRotationPoint(0.0F, 5.863F, 13.1711F);
|
||||
Body.addChild(butt);
|
||||
setRotationAngle(butt, -0.0436F, 0.0F, 0.0F);
|
||||
cube_r8 = new ModelRenderer(this);
|
||||
cube_r8.setRotationPoint(0.0F, -4.5F, 0.25F);
|
||||
butt.addChild(cube_r8);
|
||||
setRotationAngle(cube_r8, 1.2654F, 0.0F, 0.0F);
|
||||
cube_r8.setTextureOffset(54, 135).addBox(-4.0F, 0.2132F, -9.2426F, 8.0F, 21.0F, 10.0F, 0.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
Head.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.antenna.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.RightLegs2.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
|
||||
this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.RightLegs.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftLegs.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.LeftLegs2.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.antenna2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.butt.rotateAngleX = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.procedures.TigerFishEntityShakingConditionProcedure;
|
||||
import studio.halbear.hem.entity.GoldFishEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GoldFishRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(GoldFishEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new Modelgoldfish(), 0.2f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/goldfish.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean func_230495_a_(LivingEntity _ent) {
|
||||
Entity entity = _ent;
|
||||
World world = entity.world;
|
||||
double x = entity.getPosX();
|
||||
double y = entity.getPosY();
|
||||
double z = entity.getPosZ();
|
||||
return TigerFishEntityShakingConditionProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.4
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class Modelgoldfish extends EntityModel<Entity> {
|
||||
private final ModelRenderer Head;
|
||||
private final ModelRenderer Body;
|
||||
private final ModelRenderer LeftFin;
|
||||
private final ModelRenderer LeftFin_r1;
|
||||
private final ModelRenderer RightFin;
|
||||
private final ModelRenderer RightFin_r1;
|
||||
private final ModelRenderer TailFin2;
|
||||
private final ModelRenderer TailFin;
|
||||
|
||||
public Modelgoldfish() {
|
||||
textureWidth = 64;
|
||||
textureHeight = 64;
|
||||
Head = new ModelRenderer(this);
|
||||
Head.setRotationPoint(0.0F, 21.0F, -1.0F);
|
||||
Body = new ModelRenderer(this);
|
||||
Body.setRotationPoint(0.0F, 1.0F, 4.0F);
|
||||
Head.addChild(Body);
|
||||
Body.setTextureOffset(24, 19).addBox(-1.0F, -2.0F, -6.0F, 2.0F, 4.0F, 6.0F, 0.0F, false);
|
||||
Body.setTextureOffset(0, 0).addBox(0.0F, -5.0F, -9.0F, 0.0F, 10.0F, 9.0F, 0.0F, false);
|
||||
LeftFin = new ModelRenderer(this);
|
||||
LeftFin.setRotationPoint(1.0F, 0.0F, -3.0F);
|
||||
Body.addChild(LeftFin);
|
||||
LeftFin_r1 = new ModelRenderer(this);
|
||||
LeftFin_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
LeftFin.addChild(LeftFin_r1);
|
||||
setRotationAngle(LeftFin_r1, 0.0F, 0.0F, 0.5236F);
|
||||
LeftFin_r1.setTextureOffset(0, 19).addBox(0.0F, 0.0F, -3.0F, 6.0F, 0.0F, 6.0F, 0.0F, false);
|
||||
RightFin = new ModelRenderer(this);
|
||||
RightFin.setRotationPoint(-1.0F, 0.0F, -3.0F);
|
||||
Body.addChild(RightFin);
|
||||
RightFin_r1 = new ModelRenderer(this);
|
||||
RightFin_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightFin.addChild(RightFin_r1);
|
||||
setRotationAngle(RightFin_r1, 0.0F, 0.0F, -0.5236F);
|
||||
RightFin_r1.setTextureOffset(0, 19).addBox(-6.0F, 0.0F, -3.0F, 6.0F, 0.0F, 6.0F, 0.0F, true);
|
||||
TailFin2 = new ModelRenderer(this);
|
||||
TailFin2.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
Body.addChild(TailFin2);
|
||||
TailFin = new ModelRenderer(this);
|
||||
TailFin.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
TailFin2.addChild(TailFin);
|
||||
TailFin.setTextureOffset(18, 0).addBox(0.0F, -5.0F, 0.0F, 0.0F, 10.0F, 9.0F, 0.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
Head.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.TailFin.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.LeftFin.rotateAngleZ = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.TailFin2.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.Body.rotateAngleY = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.RightFin.rotateAngleZ = MathHelper.cos(f * 0.6662F) * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,155 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.LadyBugInFlightEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class LadyBugInFlightRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(LadyBugInFlightEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelLadyBirdInFlight(), 0.3f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/ladybug.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.4
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelLadyBirdInFlight extends EntityModel<Entity> {
|
||||
private final ModelRenderer Body;
|
||||
private final ModelRenderer RightLeg;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer LeftLeg;
|
||||
private final ModelRenderer cube_r2;
|
||||
private final ModelRenderer RightLeg2;
|
||||
private final ModelRenderer cube_r3;
|
||||
private final ModelRenderer LeftLeg2;
|
||||
private final ModelRenderer cube_r4;
|
||||
private final ModelRenderer rightwing;
|
||||
private final ModelRenderer cube_r5;
|
||||
private final ModelRenderer leftwing;
|
||||
private final ModelRenderer cube_r6;
|
||||
private final ModelRenderer head;
|
||||
private final ModelRenderer cube_r7;
|
||||
|
||||
public ModelLadyBirdInFlight() {
|
||||
textureWidth = 32;
|
||||
textureHeight = 32;
|
||||
Body = new ModelRenderer(this);
|
||||
Body.setRotationPoint(0.0F, 21.0F, -2.0F);
|
||||
setRotationAngle(Body, -0.2182F, 0.0F, 0.0F);
|
||||
Body.setTextureOffset(0, 0).addBox(-2.0F, 0.0F, 0.0F, 4.0F, 3.0F, 5.0F, 0.0F, false);
|
||||
RightLeg = new ModelRenderer(this);
|
||||
RightLeg.setRotationPoint(-2.0F, 2.25F, 2.5F);
|
||||
Body.addChild(RightLeg);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
RightLeg.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0F, 0.0F, -0.5236F);
|
||||
cube_r1.setTextureOffset(19, 2).addBox(-2.0F, 0.0F, 2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
cube_r1.setTextureOffset(19, 0).addBox(-2.0F, 0.0F, -2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
LeftLeg = new ModelRenderer(this);
|
||||
LeftLeg.setRotationPoint(2.0F, 2.25F, 2.5F);
|
||||
Body.addChild(LeftLeg);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
LeftLeg.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 0.0F, 0.0F, 0.5236F);
|
||||
cube_r2.setTextureOffset(22, 20).addBox(0.0F, 0.0F, 2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
cube_r2.setTextureOffset(19, 6).addBox(0.0F, 0.0F, -2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
RightLeg2 = new ModelRenderer(this);
|
||||
RightLeg2.setRotationPoint(2.0F, 2.25F, 2.5F);
|
||||
Body.addChild(RightLeg2);
|
||||
cube_r3 = new ModelRenderer(this);
|
||||
cube_r3.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
RightLeg2.addChild(cube_r3);
|
||||
setRotationAngle(cube_r3, 0.0F, 0.0F, 0.5236F);
|
||||
cube_r3.setTextureOffset(22, 18).addBox(0.0F, 0.0F, 0.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
LeftLeg2 = new ModelRenderer(this);
|
||||
LeftLeg2.setRotationPoint(-2.0F, 2.25F, 2.5F);
|
||||
Body.addChild(LeftLeg2);
|
||||
cube_r4 = new ModelRenderer(this);
|
||||
cube_r4.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
LeftLeg2.addChild(cube_r4);
|
||||
setRotationAngle(cube_r4, 0.0F, 0.0F, -0.5236F);
|
||||
cube_r4.setTextureOffset(19, 4).addBox(-2.0F, 0.0F, 0.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
rightwing = new ModelRenderer(this);
|
||||
rightwing.setRotationPoint(-0.1F, 20.95F, -2.15F);
|
||||
setRotationAngle(rightwing, 0.108F, -0.404F, 0.7438F);
|
||||
cube_r5 = new ModelRenderer(this);
|
||||
cube_r5.setRotationPoint(-2.101F, 0.2457F, -0.1112F);
|
||||
rightwing.addChild(cube_r5);
|
||||
setRotationAngle(cube_r5, 0.0451F, -0.1289F, -0.0229F);
|
||||
cube_r5.setTextureOffset(0, 9).addBox(0.0F, 0.0F, 0.0F, 2.0F, 3.0F, 5.0F, 0.2F, false);
|
||||
leftwing = new ModelRenderer(this);
|
||||
leftwing.setRotationPoint(0.1F, 20.95F, -2.1F);
|
||||
setRotationAngle(leftwing, 0.127F, 0.532F, -0.6743F);
|
||||
cube_r6 = new ModelRenderer(this);
|
||||
cube_r6.setRotationPoint(2.1007F, 0.243F, -0.164F);
|
||||
leftwing.addChild(cube_r6);
|
||||
setRotationAngle(cube_r6, 0.0451F, 0.1289F, 0.0229F);
|
||||
cube_r6.setTextureOffset(15, 9).addBox(-2.0F, 0.0F, 0.0F, 2.0F, 3.0F, 5.0F, 0.2F, false);
|
||||
head = new ModelRenderer(this);
|
||||
head.setRotationPoint(0.0F, 22.5F, -2.25F);
|
||||
head.setTextureOffset(13, 18).addBox(-1.0F, -1.0F, -2.0F, 2.0F, 2.0F, 2.0F, 0.0F, false);
|
||||
cube_r7 = new ModelRenderer(this);
|
||||
cube_r7.setRotationPoint(0.5F, -1.0F, -2.0F);
|
||||
head.addChild(cube_r7);
|
||||
setRotationAngle(cube_r7, 0.48F, 0.0F, 0.0F);
|
||||
cube_r7.setTextureOffset(0, 18).addBox(-3.0F, -4.0F, 0.0F, 5.0F, 4.0F, 0.0F, 0.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
rightwing.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
leftwing.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
head.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.LeftLeg.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightLeg2.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftLeg2.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.rightwing.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.leftwing.rotateAngleY = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.head.rotateAngleY = f3 / (180F / (float) Math.PI);
|
||||
this.head.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.RightLeg.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.Body.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.entity.LadybugEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class LadybugRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(LadybugEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelLadyBird(), 0.3f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/ladybug.png");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.4
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelLadyBird extends EntityModel<Entity> {
|
||||
private final ModelRenderer rightwing;
|
||||
private final ModelRenderer cube_r1;
|
||||
private final ModelRenderer leftwing;
|
||||
private final ModelRenderer cube_r2;
|
||||
private final ModelRenderer head;
|
||||
private final ModelRenderer cube_r3;
|
||||
private final ModelRenderer RightLeg;
|
||||
private final ModelRenderer cube_r4;
|
||||
private final ModelRenderer LeftLeg;
|
||||
private final ModelRenderer cube_r5;
|
||||
private final ModelRenderer RightLeg2;
|
||||
private final ModelRenderer cube_r6;
|
||||
private final ModelRenderer LeftLeg2;
|
||||
private final ModelRenderer cube_r7;
|
||||
private final ModelRenderer bb_main;
|
||||
|
||||
public ModelLadyBird() {
|
||||
textureWidth = 32;
|
||||
textureHeight = 32;
|
||||
rightwing = new ModelRenderer(this);
|
||||
rightwing.setRotationPoint(-0.1F, 20.95F, -2.15F);
|
||||
setRotationAngle(rightwing, -0.0366F, 0.0904F, 0.1661F);
|
||||
cube_r1 = new ModelRenderer(this);
|
||||
cube_r1.setRotationPoint(-2.101F, 0.2457F, -0.1112F);
|
||||
rightwing.addChild(cube_r1);
|
||||
setRotationAngle(cube_r1, 0.0451F, -0.1289F, -0.0229F);
|
||||
cube_r1.setTextureOffset(0, 9).addBox(0.0F, 0.0F, 0.0F, 2.0F, 3.0F, 5.0F, 0.2F, false);
|
||||
leftwing = new ModelRenderer(this);
|
||||
leftwing.setRotationPoint(0.1F, 20.95F, -2.1F);
|
||||
setRotationAngle(leftwing, -0.0513F, -0.0872F, -0.168F);
|
||||
cube_r2 = new ModelRenderer(this);
|
||||
cube_r2.setRotationPoint(2.1007F, 0.243F, -0.164F);
|
||||
leftwing.addChild(cube_r2);
|
||||
setRotationAngle(cube_r2, 0.0451F, 0.1289F, 0.0229F);
|
||||
cube_r2.setTextureOffset(15, 9).addBox(-2.0F, 0.0F, 0.0F, 2.0F, 3.0F, 5.0F, 0.2F, false);
|
||||
head = new ModelRenderer(this);
|
||||
head.setRotationPoint(0.0F, 23.0F, -2.0F);
|
||||
head.setTextureOffset(13, 18).addBox(-1.0F, -1.0F, -2.0F, 2.0F, 2.0F, 2.0F, 0.0F, false);
|
||||
cube_r3 = new ModelRenderer(this);
|
||||
cube_r3.setRotationPoint(0.5F, -1.0F, -2.0F);
|
||||
head.addChild(cube_r3);
|
||||
setRotationAngle(cube_r3, 0.48F, 0.0F, 0.0F);
|
||||
cube_r3.setTextureOffset(0, 18).addBox(-3.0F, -4.0F, 0.0F, 5.0F, 4.0F, 0.0F, 0.0F, false);
|
||||
RightLeg = new ModelRenderer(this);
|
||||
RightLeg.setRotationPoint(-2.0F, 23.25F, 0.5F);
|
||||
cube_r4 = new ModelRenderer(this);
|
||||
cube_r4.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
RightLeg.addChild(cube_r4);
|
||||
setRotationAngle(cube_r4, 0.0F, 0.0F, -0.5236F);
|
||||
cube_r4.setTextureOffset(19, 2).addBox(-2.0F, 0.0F, 2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
cube_r4.setTextureOffset(19, 0).addBox(-2.0F, 0.0F, -2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
LeftLeg = new ModelRenderer(this);
|
||||
LeftLeg.setRotationPoint(2.0F, 23.25F, 0.5F);
|
||||
cube_r5 = new ModelRenderer(this);
|
||||
cube_r5.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
LeftLeg.addChild(cube_r5);
|
||||
setRotationAngle(cube_r5, 0.0F, 0.0F, 0.5236F);
|
||||
cube_r5.setTextureOffset(22, 20).addBox(0.0F, 0.0F, 2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
cube_r5.setTextureOffset(19, 6).addBox(0.0F, 0.0F, -2.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
RightLeg2 = new ModelRenderer(this);
|
||||
RightLeg2.setRotationPoint(2.0F, 23.25F, 0.5F);
|
||||
cube_r6 = new ModelRenderer(this);
|
||||
cube_r6.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
RightLeg2.addChild(cube_r6);
|
||||
setRotationAngle(cube_r6, 0.0F, 0.0F, 0.5236F);
|
||||
cube_r6.setTextureOffset(22, 18).addBox(0.0F, 0.0F, 0.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
LeftLeg2 = new ModelRenderer(this);
|
||||
LeftLeg2.setRotationPoint(-2.0F, 23.25F, 0.5F);
|
||||
cube_r7 = new ModelRenderer(this);
|
||||
cube_r7.setRotationPoint(0.0F, 0.0F, -0.5F);
|
||||
LeftLeg2.addChild(cube_r7);
|
||||
setRotationAngle(cube_r7, 0.0F, 0.0F, -0.5236F);
|
||||
cube_r7.setTextureOffset(19, 4).addBox(-2.0F, 0.0F, 0.0F, 2.0F, 0.0F, 1.0F, 0.0F, false);
|
||||
bb_main = new ModelRenderer(this);
|
||||
bb_main.setRotationPoint(0.0F, 24.0F, 0.0F);
|
||||
bb_main.setTextureOffset(0, 0).addBox(-2.0F, -3.0F, -2.0F, 4.0F, 3.0F, 5.0F, 0.0F, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
rightwing.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
leftwing.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
head.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftLeg.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
RightLeg2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
LeftLeg2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
bb_main.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.LeftLeg.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightLeg2.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.LeftLeg2.rotateAngleZ = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.rightwing.rotateAngleY = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.leftwing.rotateAngleY = MathHelper.cos(f * 0.6662F) * f1;
|
||||
this.head.rotateAngleY = f3 / (180F / (float) Math.PI);
|
||||
this.head.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.RightLeg.rotateAngleZ = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
|
||||
package studio.halbear.hem.entity.renderer;
|
||||
|
||||
import studio.halbear.hem.procedures.TigerFishEntityShakingConditionProcedure;
|
||||
import studio.halbear.hem.entity.TigerFishEntity;
|
||||
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.EntityModel;
|
||||
import net.minecraft.client.renderer.entity.MobRenderer;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TigerFishRenderer {
|
||||
public static class ModelRegisterHandler {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(TigerFishEntity.entity, renderManager -> {
|
||||
return new MobRenderer(renderManager, new ModelTigerFish(), 0.5f) {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(Entity entity) {
|
||||
return new ResourceLocation("hem:textures/entities/tigerfish.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean func_230495_a_(LivingEntity _ent) {
|
||||
Entity entity = _ent;
|
||||
World world = entity.world;
|
||||
double x = entity.getPosX();
|
||||
double y = entity.getPosY();
|
||||
double z = entity.getPosZ();
|
||||
return TigerFishEntityShakingConditionProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made with Blockbench 4.12.4
|
||||
// Exported for Minecraft version 1.15 - 1.16 with MCP mappings
|
||||
// Paste this class into your mod and generate all required imports
|
||||
public static class ModelTigerFish extends EntityModel<Entity> {
|
||||
private final ModelRenderer OuterBody;
|
||||
private final ModelRenderer Body;
|
||||
private final ModelRenderer HeadY;
|
||||
private final ModelRenderer leftWhisker;
|
||||
private final ModelRenderer leftWhisker_r1;
|
||||
private final ModelRenderer RightWhisker;
|
||||
private final ModelRenderer RightWhisker_r1;
|
||||
private final ModelRenderer RightFin;
|
||||
private final ModelRenderer TailFin3;
|
||||
private final ModelRenderer TailFin;
|
||||
private final ModelRenderer TailFin2;
|
||||
private final ModelRenderer leftFin;
|
||||
|
||||
public ModelTigerFish() {
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
OuterBody = new ModelRenderer(this);
|
||||
OuterBody.setRotationPoint(0.0F, 21.0F, 8.0F);
|
||||
Body = new ModelRenderer(this);
|
||||
Body.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
OuterBody.addChild(Body);
|
||||
HeadY = new ModelRenderer(this);
|
||||
HeadY.setRotationPoint(0.0F, 0.0F, -12.0F);
|
||||
Body.addChild(HeadY);
|
||||
HeadY.setTextureOffset(0, 0).addBox(-5.0F, -2.0F, -4.0F, 10.0F, 4.0F, 16.0F, 0.0F, false);
|
||||
HeadY.setTextureOffset(0, 20).addBox(-5.0F, -2.0F, -4.0F, 10.0F, 4.0F, 16.0F, 0.2F, false);
|
||||
HeadY.setTextureOffset(52, 16).addBox(0.0F, -7.0F, -4.0F, 0.0F, 11.0F, 16.0F, 0.0F, false);
|
||||
leftWhisker = new ModelRenderer(this);
|
||||
leftWhisker.setRotationPoint(2.0F, -1.0F, -4.05F);
|
||||
HeadY.addChild(leftWhisker);
|
||||
leftWhisker_r1 = new ModelRenderer(this);
|
||||
leftWhisker_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
leftWhisker.addChild(leftWhisker_r1);
|
||||
setRotationAngle(leftWhisker_r1, 0.119F, 0.734F, 0.1767F);
|
||||
leftWhisker_r1.setTextureOffset(0, 56).addBox(0.0F, -4.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F, false);
|
||||
RightWhisker = new ModelRenderer(this);
|
||||
RightWhisker.setRotationPoint(-2.0F, -1.0F, -4.05F);
|
||||
HeadY.addChild(RightWhisker);
|
||||
RightWhisker_r1 = new ModelRenderer(this);
|
||||
RightWhisker_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
RightWhisker.addChild(RightWhisker_r1);
|
||||
setRotationAngle(RightWhisker_r1, 0.1578F, -0.7279F, -0.2348F);
|
||||
RightWhisker_r1.setTextureOffset(16, 56).addBox(-8.0F, -4.0F, 0.0F, 8.0F, 7.0F, 0.0F, 0.0F, false);
|
||||
RightFin = new ModelRenderer(this);
|
||||
RightFin.setRotationPoint(-5.0F, 2.0F, 4.0F);
|
||||
HeadY.addChild(RightFin);
|
||||
RightFin.setTextureOffset(0, 40).addBox(-10.0F, 0.0F, -8.0F, 10.0F, 0.0F, 16.0F, 0.0F, false);
|
||||
TailFin3 = new ModelRenderer(this);
|
||||
TailFin3.setRotationPoint(0.0F, 0.0F, 12.0F);
|
||||
HeadY.addChild(TailFin3);
|
||||
TailFin = new ModelRenderer(this);
|
||||
TailFin.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
TailFin3.addChild(TailFin);
|
||||
TailFin2 = new ModelRenderer(this);
|
||||
TailFin2.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
TailFin.addChild(TailFin2);
|
||||
TailFin2.setTextureOffset(52, 43).addBox(0.0F, -7.0F, 0.0F, 0.0F, 11.0F, 16.0F, 0.0F, false);
|
||||
leftFin = new ModelRenderer(this);
|
||||
leftFin.setRotationPoint(5.0F, 2.0F, 4.0F);
|
||||
HeadY.addChild(leftFin);
|
||||
leftFin.setTextureOffset(0, 40).addBox(0.0F, 0.0F, -8.0F, 10.0F, 0.0F, 16.0F, 0.0F, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
||||
float alpha) {
|
||||
OuterBody.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
|
||||
this.TailFin.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.leftWhisker.rotateAngleY = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.OuterBody.rotateAngleY = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.TailFin3.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.RightWhisker.rotateAngleY = MathHelper.cos(f * 0.6662F) * f1;
|
||||
this.TailFin2.rotateAngleY = MathHelper.cos(f * 1.0F) * -1.0F * f1;
|
||||
this.leftFin.rotateAngleZ = MathHelper.cos(f * 0.6662F + (float) Math.PI) * f1;
|
||||
this.HeadY.rotateAngleX = f4 / (180F / (float) Math.PI);
|
||||
this.Body.rotateAngleY = MathHelper.cos(f * 1.0F) * 1.0F * f1;
|
||||
this.RightFin.rotateAngleZ = MathHelper.cos(f * 0.6662F) * f1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
|
||||
package studio.halbear.hem.gui;
|
||||
|
||||
import studio.halbear.hem.item.GasCanister612litreItem;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
import studio.halbear.hem.HemMod;
|
||||
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.network.IContainerFactory;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class AirboatGasCelViewGui extends HemModElements.ModElement {
|
||||
public static HashMap guistate = new HashMap();
|
||||
private static ContainerType<GuiContainerMod> containerType = null;
|
||||
|
||||
public AirboatGasCelViewGui(HemModElements instance) {
|
||||
super(instance, 309);
|
||||
elements.addNetworkMessage(ButtonPressedMessage.class, ButtonPressedMessage::buffer, ButtonPressedMessage::new,
|
||||
ButtonPressedMessage::handler);
|
||||
elements.addNetworkMessage(GUISlotChangedMessage.class, GUISlotChangedMessage::buffer, GUISlotChangedMessage::new,
|
||||
GUISlotChangedMessage::handler);
|
||||
containerType = new ContainerType<>(new GuiContainerModFactory());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(new ContainerRegisterHandler());
|
||||
}
|
||||
|
||||
private static class ContainerRegisterHandler {
|
||||
@SubscribeEvent
|
||||
public void registerContainer(RegistryEvent.Register<ContainerType<?>> event) {
|
||||
event.getRegistry().register(containerType.setRegistryName("airboat_gas_cel_view"));
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void initElements() {
|
||||
DeferredWorkQueue.runLater(() -> ScreenManager.registerFactory(containerType, AirboatGasCelViewGuiWindow::new));
|
||||
}
|
||||
|
||||
public static class GuiContainerModFactory implements IContainerFactory {
|
||||
public GuiContainerMod create(int id, PlayerInventory inv, PacketBuffer extraData) {
|
||||
return new GuiContainerMod(id, inv, extraData);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GuiContainerMod extends Container implements Supplier<Map<Integer, Slot>> {
|
||||
World world;
|
||||
PlayerEntity entity;
|
||||
int x, y, z;
|
||||
private IItemHandler internal;
|
||||
private Map<Integer, Slot> customSlots = new HashMap<>();
|
||||
private boolean bound = false;
|
||||
|
||||
public GuiContainerMod(int id, PlayerInventory inv, PacketBuffer extraData) {
|
||||
super(containerType, id);
|
||||
this.entity = inv.player;
|
||||
this.world = inv.player.world;
|
||||
this.internal = new ItemStackHandler(7);
|
||||
BlockPos pos = null;
|
||||
if (extraData != null) {
|
||||
pos = extraData.readBlockPos();
|
||||
this.x = pos.getX();
|
||||
this.y = pos.getY();
|
||||
this.z = pos.getZ();
|
||||
}
|
||||
if (pos != null) {
|
||||
if (extraData.readableBytes() == 1) { // bound to item
|
||||
byte hand = extraData.readByte();
|
||||
ItemStack itemstack;
|
||||
if (hand == 0)
|
||||
itemstack = this.entity.getHeldItemMainhand();
|
||||
else
|
||||
itemstack = this.entity.getHeldItemOffhand();
|
||||
itemstack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
|
||||
this.internal = capability;
|
||||
this.bound = true;
|
||||
});
|
||||
} else if (extraData.readableBytes() > 1) {
|
||||
extraData.readByte(); // drop padding
|
||||
Entity entity = world.getEntityByID(extraData.readVarInt());
|
||||
if (entity != null)
|
||||
entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
|
||||
this.internal = capability;
|
||||
this.bound = true;
|
||||
});
|
||||
} else { // might be bound to block
|
||||
TileEntity ent = inv.player != null ? inv.player.world.getTileEntity(pos) : null;
|
||||
if (ent != null) {
|
||||
ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
|
||||
this.internal = capability;
|
||||
this.bound = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 261, 44) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return (GasCanister612litreItem.block == stack.getItem());
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(1, this.addSlot(new SlotItemHandler(internal, 1, 283, 44) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return (GasCanister612litreItem.block == stack.getItem());
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(2, this.addSlot(new SlotItemHandler(internal, 2, 305, 44) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return (GasCanister612litreItem.block == stack.getItem());
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(3, this.addSlot(new SlotItemHandler(internal, 3, 327, 44) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return (GasCanister612litreItem.block == stack.getItem());
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(4, this.addSlot(new SlotItemHandler(internal, 4, 349, 44) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return (GasCanister612litreItem.block == stack.getItem());
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(5, this.addSlot(new SlotItemHandler(internal, 5, 371, 44) {
|
||||
}));
|
||||
this.customSlots.put(6, this.addSlot(new SlotItemHandler(internal, 6, 393, 44) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return (GasCanister612litreItem.block == stack.getItem());
|
||||
}
|
||||
}));
|
||||
int si;
|
||||
int sj;
|
||||
for (si = 0; si < 3; ++si)
|
||||
for (sj = 0; sj < 9; ++sj)
|
||||
this.addSlot(new Slot(inv, sj + (si + 1) * 9, 254 + 8 + sj * 18, 0 + 84 + si * 18));
|
||||
for (si = 0; si < 9; ++si)
|
||||
this.addSlot(new Slot(inv, si, 254 + 8 + si * 18, 0 + 142));
|
||||
}
|
||||
|
||||
public Map<Integer, Slot> get() {
|
||||
return customSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
if (index < 7) {
|
||||
if (!this.mergeItemStack(itemstack1, 7, this.inventorySlots.size(), true)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
} else if (!this.mergeItemStack(itemstack1, 0, 7, false)) {
|
||||
if (index < 7 + 27) {
|
||||
if (!this.mergeItemStack(itemstack1, 7 + 27, this.inventorySlots.size(), true)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else {
|
||||
if (!this.mergeItemStack(itemstack1, 7, 7 + 27, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (itemstack1.getCount() == 0) {
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (itemstack1.getCount() == itemstack.getCount()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override /**
|
||||
* Merges provided ItemStack with the first avaliable one in the container/player inventor between minIndex (included) and maxIndex (excluded). Args : stack, minIndex, maxIndex, negativDirection. /!\ the Container implementation do not check if the item is valid for the slot
|
||||
*/
|
||||
protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) {
|
||||
boolean flag = false;
|
||||
int i = startIndex;
|
||||
if (reverseDirection) {
|
||||
i = endIndex - 1;
|
||||
}
|
||||
if (stack.isStackable()) {
|
||||
while (!stack.isEmpty()) {
|
||||
if (reverseDirection) {
|
||||
if (i < startIndex) {
|
||||
break;
|
||||
}
|
||||
} else if (i >= endIndex) {
|
||||
break;
|
||||
}
|
||||
Slot slot = this.inventorySlots.get(i);
|
||||
ItemStack itemstack = slot.getStack();
|
||||
if (slot.isItemValid(itemstack) && !itemstack.isEmpty() && areItemsAndTagsEqual(stack, itemstack)) {
|
||||
int j = itemstack.getCount() + stack.getCount();
|
||||
int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize());
|
||||
if (j <= maxSize) {
|
||||
stack.setCount(0);
|
||||
itemstack.setCount(j);
|
||||
slot.putStack(itemstack);
|
||||
flag = true;
|
||||
} else if (itemstack.getCount() < maxSize) {
|
||||
stack.shrink(maxSize - itemstack.getCount());
|
||||
itemstack.setCount(maxSize);
|
||||
slot.putStack(itemstack);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (reverseDirection) {
|
||||
--i;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!stack.isEmpty()) {
|
||||
if (reverseDirection) {
|
||||
i = endIndex - 1;
|
||||
} else {
|
||||
i = startIndex;
|
||||
}
|
||||
while (true) {
|
||||
if (reverseDirection) {
|
||||
if (i < startIndex) {
|
||||
break;
|
||||
}
|
||||
} else if (i >= endIndex) {
|
||||
break;
|
||||
}
|
||||
Slot slot1 = this.inventorySlots.get(i);
|
||||
ItemStack itemstack1 = slot1.getStack();
|
||||
if (itemstack1.isEmpty() && slot1.isItemValid(stack)) {
|
||||
if (stack.getCount() > slot1.getSlotStackLimit()) {
|
||||
slot1.putStack(stack.split(slot1.getSlotStackLimit()));
|
||||
} else {
|
||||
slot1.putStack(stack.split(stack.getCount()));
|
||||
}
|
||||
slot1.onSlotChanged();
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
if (reverseDirection) {
|
||||
--i;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(PlayerEntity playerIn) {
|
||||
super.onContainerClosed(playerIn);
|
||||
if (!bound && (playerIn instanceof ServerPlayerEntity)) {
|
||||
if (!playerIn.isAlive() || playerIn instanceof ServerPlayerEntity && ((ServerPlayerEntity) playerIn).hasDisconnected()) {
|
||||
for (int j = 0; j < internal.getSlots(); ++j) {
|
||||
playerIn.dropItem(internal.extractItem(j, internal.getStackInSlot(j).getCount(), false), false);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < internal.getSlots(); ++i) {
|
||||
playerIn.inventory.placeItemBackInInventory(playerIn.world,
|
||||
internal.extractItem(i, internal.getStackInSlot(i).getCount(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void slotChanged(int slotid, int ctype, int meta) {
|
||||
if (this.world != null && this.world.isRemote()) {
|
||||
HemMod.PACKET_HANDLER.sendToServer(new GUISlotChangedMessage(slotid, x, y, z, ctype, meta));
|
||||
handleSlotAction(entity, slotid, ctype, meta, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ButtonPressedMessage {
|
||||
int buttonID, x, y, z;
|
||||
|
||||
public ButtonPressedMessage(PacketBuffer buffer) {
|
||||
this.buttonID = buffer.readInt();
|
||||
this.x = buffer.readInt();
|
||||
this.y = buffer.readInt();
|
||||
this.z = buffer.readInt();
|
||||
}
|
||||
|
||||
public ButtonPressedMessage(int buttonID, int x, int y, int z) {
|
||||
this.buttonID = buttonID;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static void buffer(ButtonPressedMessage message, PacketBuffer buffer) {
|
||||
buffer.writeInt(message.buttonID);
|
||||
buffer.writeInt(message.x);
|
||||
buffer.writeInt(message.y);
|
||||
buffer.writeInt(message.z);
|
||||
}
|
||||
|
||||
public static void handler(ButtonPressedMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
PlayerEntity entity = context.getSender();
|
||||
int buttonID = message.buttonID;
|
||||
int x = message.x;
|
||||
int y = message.y;
|
||||
int z = message.z;
|
||||
handleButtonAction(entity, buttonID, x, y, z);
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GUISlotChangedMessage {
|
||||
int slotID, x, y, z, changeType, meta;
|
||||
|
||||
public GUISlotChangedMessage(int slotID, int x, int y, int z, int changeType, int meta) {
|
||||
this.slotID = slotID;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.changeType = changeType;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public GUISlotChangedMessage(PacketBuffer buffer) {
|
||||
this.slotID = buffer.readInt();
|
||||
this.x = buffer.readInt();
|
||||
this.y = buffer.readInt();
|
||||
this.z = buffer.readInt();
|
||||
this.changeType = buffer.readInt();
|
||||
this.meta = buffer.readInt();
|
||||
}
|
||||
|
||||
public static void buffer(GUISlotChangedMessage message, PacketBuffer buffer) {
|
||||
buffer.writeInt(message.slotID);
|
||||
buffer.writeInt(message.x);
|
||||
buffer.writeInt(message.y);
|
||||
buffer.writeInt(message.z);
|
||||
buffer.writeInt(message.changeType);
|
||||
buffer.writeInt(message.meta);
|
||||
}
|
||||
|
||||
public static void handler(GUISlotChangedMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
PlayerEntity entity = context.getSender();
|
||||
int slotID = message.slotID;
|
||||
int changeType = message.changeType;
|
||||
int meta = message.meta;
|
||||
int x = message.x;
|
||||
int y = message.y;
|
||||
int z = message.z;
|
||||
handleSlotAction(entity, slotID, changeType, meta, x, y, z);
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
||||
static void handleButtonAction(PlayerEntity entity, int buttonID, int x, int y, int z) {
|
||||
World world = entity.world;
|
||||
// security measure to prevent arbitrary chunk generation
|
||||
if (!world.isBlockLoaded(new BlockPos(x, y, z)))
|
||||
return;
|
||||
}
|
||||
|
||||
private static void handleSlotAction(PlayerEntity entity, int slotID, int changeType, int meta, int x, int y, int z) {
|
||||
World world = entity.world;
|
||||
// security measure to prevent arbitrary chunk generation
|
||||
if (!world.isBlockLoaded(new BlockPos(x, y, z)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
|
||||
package studio.halbear.hem.gui;
|
||||
|
||||
import studio.halbear.hem.HemMod;
|
||||
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class AirboatGasCelViewGuiWindow extends ContainerScreen<AirboatGasCelViewGui.GuiContainerMod> {
|
||||
private World world;
|
||||
private int x, y, z;
|
||||
private PlayerEntity entity;
|
||||
private final static HashMap guistate = AirboatGasCelViewGui.guistate;
|
||||
|
||||
public AirboatGasCelViewGuiWindow(AirboatGasCelViewGui.GuiContainerMod container, PlayerInventory inventory, ITextComponent text) {
|
||||
super(container, inventory, text);
|
||||
this.world = container.world;
|
||||
this.x = container.x;
|
||||
this.y = container.y;
|
||||
this.z = container.z;
|
||||
this.entity = container.entity;
|
||||
this.xSize = 428;
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("hem:textures/screens/airboat_gas_cel_view.png");
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(ms);
|
||||
super.render(ms, mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredTooltip(ms, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack ms, float partialTicks, int gx, int gy) {
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.blit(ms, k, l, 0, 0, this.xSize, this.ySize, this.xSize, this.ySize);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/airshipheliumui.png"));
|
||||
this.blit(ms, this.guiLeft + 2, this.guiTop + 3, 0, 0, 256, 139, 256, 139);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluibottom.png"));
|
||||
this.blit(ms, this.guiLeft + 61, this.guiTop + 96, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluiprogress.png"));
|
||||
this.blit(ms, this.guiLeft + 61, this.guiTop + 90, 0, 0, 22, 6, 22, 6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluitop.png"));
|
||||
this.blit(ms, this.guiLeft + 61, this.guiTop + 85, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluibottom.png"));
|
||||
this.blit(ms, this.guiLeft + 85, this.guiTop + 96, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluitop.png"));
|
||||
this.blit(ms, this.guiLeft + 85, this.guiTop + 85, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluiprogress.png"));
|
||||
this.blit(ms, this.guiLeft + 85, this.guiTop + 90, 0, 0, 22, 6, 22, 6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluibottom.png"));
|
||||
this.blit(ms, this.guiLeft + 37, this.guiTop + 92, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluitop.png"));
|
||||
this.blit(ms, this.guiLeft + 37, this.guiTop + 81, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluiprogress.png"));
|
||||
this.blit(ms, this.guiLeft + 37, this.guiTop + 86, 0, 0, 22, 6, 22, 6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluibottom.png"));
|
||||
this.blit(ms, this.guiLeft + 109, this.guiTop + 96, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluibottom.png"));
|
||||
this.blit(ms, this.guiLeft + 133, this.guiTop + 96, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluibottom.png"));
|
||||
this.blit(ms, this.guiLeft + 157, this.guiTop + 92, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluibottom.png"));
|
||||
this.blit(ms, this.guiLeft + 181, this.guiTop + 86, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluiprogress.png"));
|
||||
this.blit(ms, this.guiLeft + 109, this.guiTop + 90, 0, 0, 22, 6, 22, 6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluiprogress.png"));
|
||||
this.blit(ms, this.guiLeft + 133, this.guiTop + 90, 0, 0, 22, 6, 22, 6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluiprogress.png"));
|
||||
this.blit(ms, this.guiLeft + 157, this.guiTop + 86, 0, 0, 22, 6, 22, 6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluiprogress.png"));
|
||||
this.blit(ms, this.guiLeft + 181, this.guiTop + 80, 0, 0, 22, 6, 22, 6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluitop.png"));
|
||||
this.blit(ms, this.guiLeft + 109, this.guiTop + 85, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluitop.png"));
|
||||
this.blit(ms, this.guiLeft + 133, this.guiTop + 85, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluitop.png"));
|
||||
this.blit(ms, this.guiLeft + 157, this.guiTop + 81, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/heliumfilluitop.png"));
|
||||
this.blit(ms, this.guiLeft + 181, this.guiTop + 75, 0, 0, 22, 5, 22, 5);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, int b, int c) {
|
||||
if (key == 256) {
|
||||
this.minecraft.player.closeScreen();
|
||||
return true;
|
||||
}
|
||||
return super.keyPressed(key, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack ms, int mouseX, int mouseY) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
super.onClose();
|
||||
Minecraft.getInstance().keyboardListener.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Minecraft minecraft, int width, int height) {
|
||||
super.init(minecraft, width, height);
|
||||
minecraft.keyboardListener.enableRepeatEvents(true);
|
||||
this.addButton(new Button(this.guiLeft + 260, this.guiTop + 62, 92, 20, new StringTextComponent("Fill Gas Cels"), e -> {
|
||||
if (true) {
|
||||
HemMod.PACKET_HANDLER.sendToServer(new AirboatGasCelViewGui.ButtonPressedMessage(0, x, y, z));
|
||||
AirboatGasCelViewGui.handleButtonAction(entity, 0, x, y, z);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
|
||||
package studio.halbear.hem.gui.overlay;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import studio.halbear.hem.HemModVariables;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class AltimeterOverlay {
|
||||
static ResourceLocation[] AltimeterNumbers = new ResourceLocation[10];
|
||||
static ResourceLocation[] AltimeterNumbersDecimal = new ResourceLocation[10];
|
||||
static{
|
||||
for(int i = 0; i < 10; i++){
|
||||
AltimeterNumbers[i] = new ResourceLocation("hem:textures/screens/odometernumber"+i+ ".png");
|
||||
AltimeterNumbersDecimal[i] = new ResourceLocation("hem:textures/screens/odometernumberdecimal"+i+ ".png");
|
||||
}
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public static void eventHandler(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
|
||||
int w = event.getWindow().getScaledWidth();
|
||||
int h = event.getWindow().getScaledHeight();
|
||||
int posX = w / 2;
|
||||
int posY = h / 2;
|
||||
World _world = null;
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
double _z = 0;
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
if (entity != null) {
|
||||
_world = entity.world;
|
||||
_x = entity.getPosX();
|
||||
_y = entity.getPosY();
|
||||
_z = entity.getPosZ();
|
||||
}
|
||||
World world = _world;
|
||||
double x = _x;
|
||||
double y = _y;
|
||||
double z = _z;
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (entity.isPassenger() && EntityTypeTags.getCollection().getTagByID(new ResourceLocation("hem:hem_altitude_vehicles"))
|
||||
.contains((entity.getRidingEntity()).getType())) {
|
||||
String AltimeterValue = "";
|
||||
if((entity.getCapability(HemModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HemModVariables.PlayerVariables())).Altimeter < 9999.9){
|
||||
AltimeterValue = String.valueOf(Math.max(Math.round((entity.getCapability(HemModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HemModVariables.PlayerVariables())).Altimeter * 10.0),0)/10.0);
|
||||
} else{
|
||||
AltimeterValue = "9999.9";
|
||||
}
|
||||
AltimeterValue = AltimeterValue.replace(".", "");
|
||||
char[] OdemeterValues = AltimeterValue.toCharArray();
|
||||
int[] indexes = new int[5];
|
||||
for(int i = 5; i > 0; i--){
|
||||
if(i <= OdemeterValues.length){
|
||||
indexes[5 - i] = Integer.parseInt("" + OdemeterValues[OdemeterValues.length - i]);
|
||||
} else{
|
||||
indexes[5 - i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/altimeter.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*6, h/12, 0, 0, (h/6)*2, h/6, (h/6)*2, h/6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(AltimeterNumbers[indexes[0]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*6 + (h/6)*2*8/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(AltimeterNumbers[indexes[1]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*6 + (h/6)*2*30/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(AltimeterNumbers[indexes[2]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*6 + (h/6)*2*52/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(AltimeterNumbers[indexes[3]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*6 + (h/6)*2*74/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(AltimeterNumbersDecimal[indexes[4]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*6 + (h/6)*2*101/128,h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
|
||||
package studio.halbear.hem.gui.overlay;
|
||||
|
||||
import studio.halbear.hem.procedures.GooedOverlayDisplayOverlayIngameProcedure;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class GooedOverlayOverlay {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public static void eventHandler(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
|
||||
int w = event.getWindow().getScaledWidth();
|
||||
int h = event.getWindow().getScaledHeight();
|
||||
int posX = w / 2;
|
||||
int posY = h / 2;
|
||||
World _world = null;
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
double _z = 0;
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
if (entity != null) {
|
||||
_world = entity.world;
|
||||
_x = entity.getPosX();
|
||||
_y = entity.getPosY();
|
||||
_z = entity.getPosZ();
|
||||
}
|
||||
World world = _world;
|
||||
double x = _x;
|
||||
double y = _y;
|
||||
double z = _z;
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (GooedOverlayDisplayOverlayIngameProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll))) {
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/transparentgreen.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), 0, 0, 0, 0, w, h, w, h);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -110, posY + 20, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 106, posY + -79, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -151, posY + -59, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 118, posY + 65, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -162, posY + 61, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -35, posY + -61, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -189, posY + -92, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 32, posY + 74, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -200, posY + 9, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 124, posY + -34, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -80, posY + -81, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -29, posY + 77, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 181, posY + -57, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -177, posY + -34, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 15, posY + -102, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 75, posY + 27, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -128, posY + 93, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -126, posY + -106, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 157, posY + -89, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 75, posY + -27, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 65, posY + 80, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -227, posY + -135, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 76, posY + -141, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 211, posY + 78, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -259, posY + 85, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -100, posY + 112, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -115, posY + -137, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -22, posY + -131, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -254, posY + -65, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 219, posY + 67, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -152, posY + 13, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 31, posY + -46, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 11, posY + 23, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -35, posY + 25, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -48, posY + -6, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -72, posY + 21, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -9, posY + 44, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -70, posY + 60, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -92, posY + 60, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 61, posY + -86, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 35, posY + 1, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -82, posY + -27, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -33, posY + -35, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 5, posY + 3, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -82, posY + 3, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 158, posY + 21, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 191, posY + 46, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -121, posY + -26, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed3.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + -217, posY + 85, 0, 0, 32, 32, 32, 32);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 182, posY + 96, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed2.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 189, posY + -116, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/gooed1.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), posX + 89, posY + -119, 0, 0, 16, 16, 16, 16);
|
||||
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
package studio.halbear.hem.gui.overlay;
|
||||
|
||||
import studio.halbear.hem.procedures.HotAirBalloonUIDisplayOverlayIngame2Procedure;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class HotAirBalloonUIOverlay {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventHandler(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
|
||||
int w = event.getWindow().getScaledWidth();
|
||||
int h = event.getWindow().getScaledHeight();
|
||||
int posX = w / 2;
|
||||
int posY = h / 2;
|
||||
World _world = null;
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
double _z = 0;
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
if (entity != null) {
|
||||
_world = entity.world;
|
||||
_x = entity.getPosX();
|
||||
_y = entity.getPosY();
|
||||
_z = entity.getPosZ();
|
||||
}
|
||||
World world = _world;
|
||||
double x = _x;
|
||||
double y = _y;
|
||||
double z = _z;
|
||||
if (HotAirBalloonUIDisplayOverlayIngame2Procedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("entity", entity))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll))) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
|
||||
package studio.halbear.hem.gui.overlay;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import studio.halbear.hem.HemModVariables;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class OdometerOverlay {
|
||||
static ResourceLocation[] OdometerNumbers = new ResourceLocation[10];
|
||||
static ResourceLocation[] OdometerNumbersDecimal = new ResourceLocation[10];
|
||||
static{
|
||||
for(int i = 0; i < 10; i++){
|
||||
OdometerNumbers[i] = new ResourceLocation("hem:textures/screens/odometernumber"+i+ ".png");
|
||||
OdometerNumbersDecimal[i] = new ResourceLocation("hem:textures/screens/odometernumberdecimal"+i+ ".png");
|
||||
}
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public static void eventHandler(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
|
||||
int w = event.getWindow().getScaledWidth();
|
||||
int h = event.getWindow().getScaledHeight();
|
||||
int posX = w / 2;
|
||||
int posY = h / 2;
|
||||
World _world = null;
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
double _z = 0;
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
if (entity != null) {
|
||||
_world = entity.world;
|
||||
_x = entity.getPosX();
|
||||
_y = entity.getPosY();
|
||||
_z = entity.getPosZ();
|
||||
}
|
||||
World world = _world;
|
||||
double x = _x;
|
||||
double y = _y;
|
||||
double z = _z;
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (entity.isPassenger() && EntityTypeTags.getCollection().getTagByID(new ResourceLocation("hem:hem_odometer_vehicles"))
|
||||
.contains((entity.getRidingEntity()).getType())) {
|
||||
String OdometerValue = "";
|
||||
if((entity.getCapability(HemModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HemModVariables.PlayerVariables())).VehicleOdometer < 9999.9){
|
||||
OdometerValue = String.valueOf(Math.round((entity.getCapability(HemModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HemModVariables.PlayerVariables())).VehicleOdometer * 10.0)/10.0);
|
||||
} else{
|
||||
OdometerValue = "9999.9";
|
||||
}
|
||||
OdometerValue = OdometerValue.replace(".", "");
|
||||
char[] OdemeterValues = OdometerValue.toCharArray();
|
||||
int[] indexes = new int[5];
|
||||
for(int i = 5; i > 0; i--){
|
||||
if(i <= OdemeterValues.length){
|
||||
indexes[5 - i] = Integer.parseInt("" + OdemeterValues[OdemeterValues.length - i]);
|
||||
} else{
|
||||
indexes[5 - i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/odometer.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*3, h/12, 0, 0, (h/6)*2, h/6, (h/6)*2, h/6);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(OdometerNumbers[indexes[0]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*3 + (h/6)*2*8/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(OdometerNumbers[indexes[1]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*3 + (h/6)*2*30/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(OdometerNumbers[indexes[2]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*3 + (h/6)*2*52/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(OdometerNumbers[indexes[3]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*3 + (h/6)*2*74/128, h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(OdometerNumbersDecimal[indexes[4]]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/8)*3 + (h/6)*2*101/128,h/12 + (h/6)*19/64, 0, 0, (h/6)* 20/64, (h/6) * 37/64, (h/6)* 20/64, (h/6) * 37/64);
|
||||
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
|
||||
package studio.halbear.hem.gui.overlay;
|
||||
|
||||
import studio.halbear.hem.HemModVariables;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class PressureGaugeOverlay {
|
||||
static ResourceLocation[] GaugeTextures = new ResourceLocation[32];
|
||||
static{
|
||||
for(int i = 0; i < 32; i++){
|
||||
GaugeTextures[i] = new ResourceLocation("hem:textures/screens/hotairballoonpressureguage"+i+ ".png");
|
||||
}
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventHandler(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
|
||||
int w = event.getWindow().getScaledWidth();
|
||||
int h = event.getWindow().getScaledHeight();
|
||||
int posX = w / 2;
|
||||
int posY = h / 2;
|
||||
World _world = null;
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
double _z = 0;
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
if (entity != null) {
|
||||
_world = entity.world;
|
||||
_x = entity.getPosX();
|
||||
_y = entity.getPosY();
|
||||
_z = entity.getPosZ();
|
||||
}
|
||||
World world = _world;
|
||||
double x = _x;
|
||||
double y = _y;
|
||||
double z = _z;
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (entity.isPassenger() && EntityTypeTags.getCollection().getTagByID(new ResourceLocation("hem:hem_pressure_vehicles"))
|
||||
.contains((entity.getRidingEntity()).getType())) {
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/pipe.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w/20 + h/6,h- (int)(h/5.5), 0, 0, h/6, (h/6)*4, h/6, (h/6)*4);
|
||||
|
||||
int Index = (int)Math.floor((Math.floor(32 * ((entity.getCapability(HemModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HemModVariables.PlayerVariables())).PSI/50.0)) % 32.0));
|
||||
Minecraft.getInstance().getTextureManager()
|
||||
.bindTexture(GaugeTextures[Index]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w/20 + h/6,h- (int)(h/5.5), 0, 0, h/6, h/6, h/6, h/6);
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
|
||||
package studio.halbear.hem.gui.overlay;
|
||||
|
||||
import studio.halbear.hem.HemModVariables;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class SpeedGaugeOverlay {
|
||||
static ResourceLocation[] GaugeTextures = new ResourceLocation[32];
|
||||
static{
|
||||
for(int i = 0; i < 32; i++){
|
||||
GaugeTextures[i] = new ResourceLocation("hem:textures/screens/speedgauge"+i+ ".png");
|
||||
}
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public static void eventHandler(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
|
||||
int w = event.getWindow().getScaledWidth();
|
||||
int h = event.getWindow().getScaledHeight();
|
||||
int posX = w / 2;
|
||||
int posY = h / 2;
|
||||
World _world = null;
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
double _z = 0;
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
if (entity != null) {
|
||||
_world = entity.world;
|
||||
_x = entity.getPosX();
|
||||
_y = entity.getPosY();
|
||||
_z = entity.getPosZ();
|
||||
}
|
||||
World world = _world;
|
||||
double x = _x;
|
||||
double y = _y;
|
||||
double z = _z;
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (entity.isPassenger() && EntityTypeTags.getCollection().getTagByID(new ResourceLocation("hem:hem_speed_vehicles"))
|
||||
.contains((entity.getRidingEntity()).getType())) {
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/pipe.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/6)*3, h- (int)(h/5), 0, 0, h/6, (h/6)*4, h/6, (h/6)*4);
|
||||
|
||||
int Index = (int)Math.floor((Math.floor(32 * ((entity.getCapability(HemModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HemModVariables.PlayerVariables())).MPH/80.0)) % 32.0));
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(GaugeTextures[Index]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), w - (h/6)*3, h- (int)(h/5), 0, 0, h/6, h/6, h/6, h/6);
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
|
||||
package studio.halbear.hem.gui.overlay;
|
||||
|
||||
import studio.halbear.hem.HemModVariables;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class TemperatureGaugeOverlay {
|
||||
static ResourceLocation[] GaugeTextures = new ResourceLocation[32];
|
||||
static{
|
||||
for(int i = 0; i < 32; i++){
|
||||
GaugeTextures[i] = new ResourceLocation("hem:textures/screens/tempgauge"+i+ ".png");
|
||||
}
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventHandler(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HELMET) {
|
||||
int w = event.getWindow().getScaledWidth();
|
||||
int h = event.getWindow().getScaledHeight();
|
||||
int posX = w / 2;
|
||||
int posY = h / 2;
|
||||
World _world = null;
|
||||
double _x = 0;
|
||||
double _y = 0;
|
||||
double _z = 0;
|
||||
PlayerEntity entity = Minecraft.getInstance().player;
|
||||
if (entity != null) {
|
||||
_world = entity.world;
|
||||
_x = entity.getPosX();
|
||||
_y = entity.getPosY();
|
||||
_z = entity.getPosZ();
|
||||
}
|
||||
World world = _world;
|
||||
double x = _x;
|
||||
double y = _y;
|
||||
double z = _z;
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (entity.isPassenger() && EntityTypeTags.getCollection().getTagByID(new ResourceLocation("hem:hem_heat_vehicles"))
|
||||
.contains((entity.getRidingEntity()).getType()))
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("hem:textures/screens/pipe.png"));
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), (int)(w/20) + (int)((h/6) *1.8),h- (int)(h/6.5), 0, 0, h/6, (h/6)*4, h/6, (h/6)*4);
|
||||
int Index = (int)Math.max(Math.floor((Math.floor(32 * ((entity.getCapability(HemModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new HemModVariables.PlayerVariables())).Heat/160.0)) % 32.0)),0);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(GaugeTextures[Index]);
|
||||
Minecraft.getInstance().ingameGUI.blit(event.getMatrixStack(), (int)(w/20) + (int)((h/6) *1.8),h- (int)(h/3.5), 0, 0, h/6, h/6, h/6, h/6);
|
||||
}
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.world.dimension.BlueleafDimension;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
public class BlueleafItem extends Item {
|
||||
@ObjectHolder("hem:blueleaf")
|
||||
public static final Item block = null;
|
||||
|
||||
public BlueleafItem() {
|
||||
super(new Item.Properties().group(ItemGroup.TOOLS).maxDamage(64));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context) {
|
||||
PlayerEntity entity = context.getPlayer();
|
||||
BlockPos pos = context.getPos().offset(context.getFace());
|
||||
ItemStack itemstack = context.getItem();
|
||||
World world = context.getWorld();
|
||||
if (!entity.canPlayerEdit(pos, context.getFace(), itemstack)) {
|
||||
return ActionResultType.FAIL;
|
||||
} else {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
boolean success = false;
|
||||
if (world.isAirBlock(pos) && true) {
|
||||
BlueleafDimension.portal.portalSpawn(world, pos);
|
||||
itemstack.damageItem(1, entity, c -> c.sendBreakAnimation(context.getHand()));
|
||||
success = true;
|
||||
}
|
||||
return success ? ActionResultType.SUCCESS : ActionResultType.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.procedures.ButterflySpawnEggUseOnBlockProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class ButterflySpawnEggItem extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:butterfly_spawn_egg")
|
||||
public static final Item block = null;
|
||||
|
||||
public ButterflySpawnEggItem(HemModElements instance) {
|
||||
super(instance, 43);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new ItemCustom());
|
||||
}
|
||||
|
||||
public static class ItemCustom extends Item {
|
||||
public ItemCustom() {
|
||||
super(new Item.Properties().group(BlueleafTabItemGroup.tab).maxStackSize(64).rarity(Rarity.COMMON));
|
||||
setRegistryName("butterfly_spawn_egg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
ActionResultType retval = super.onItemUseFirst(stack, context);
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
PlayerEntity entity = context.getPlayer();
|
||||
Direction direction = context.getFace();
|
||||
BlockState blockstate = world.getBlockState(pos);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
ItemStack itemstack = context.getItem();
|
||||
|
||||
ButterflySpawnEggUseOnBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity),
|
||||
new AbstractMap.SimpleEntry<>("itemstack", itemstack))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class FluffaloTuftItem extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:fluffalo_tuft")
|
||||
public static final Item block = null;
|
||||
|
||||
public FluffaloTuftItem(HemModElements instance) {
|
||||
super(instance, 273);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new ItemCustom());
|
||||
}
|
||||
|
||||
public static class ItemCustom extends Item {
|
||||
public ItemCustom() {
|
||||
super(new Item.Properties().group(BlueleafTabItemGroup.tab).maxStackSize(64).rarity(Rarity.COMMON));
|
||||
setRegistryName("fluffalo_tuft");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {
|
||||
return 1F;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.procedures.GasCanister612litreItemIsCraftedsmeltedProcedure;
|
||||
import studio.halbear.hem.procedures.GasCanister612litreItemInInventoryTickProcedure;
|
||||
import studio.halbear.hem.itemgroup.HalsExplorationModTechItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class GasCanister612litreItem extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:gas_canister_612litre")
|
||||
public static final Item block = null;
|
||||
|
||||
public GasCanister612litreItem(HemModElements instance) {
|
||||
super(instance, 308);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new ItemCustom());
|
||||
}
|
||||
|
||||
public static class ItemCustom extends Item {
|
||||
public ItemCustom() {
|
||||
super(new Item.Properties().group(HalsExplorationModTechItemGroup.tab).maxStackSize(64).rarity(Rarity.COMMON));
|
||||
setRegistryName("gas_canister_612litre");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, World world, List<ITextComponent> list, ITooltipFlag flag) {
|
||||
super.addInformation(itemstack, world, list, flag);
|
||||
list.add(new StringTextComponent("612 Litres"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack itemstack, World world, PlayerEntity entity) {
|
||||
super.onCreated(itemstack, world, entity);
|
||||
double x = entity.getPosX();
|
||||
double y = entity.getPosY();
|
||||
double z = entity.getPosZ();
|
||||
|
||||
GasCanister612litreItemIsCraftedsmeltedProcedure.executeProcedure(Stream.of(new AbstractMap.SimpleEntry<>("itemstack", itemstack))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack itemstack, World world, Entity entity, int slot, boolean selected) {
|
||||
super.inventoryTick(itemstack, world, entity, slot, selected);
|
||||
double x = entity.getPosX();
|
||||
double y = entity.getPosY();
|
||||
double z = entity.getPosZ();
|
||||
|
||||
GasCanister612litreItemInInventoryTickProcedure.executeProcedure(
|
||||
Stream.of(new AbstractMap.SimpleEntry<>("entity", entity), new AbstractMap.SimpleEntry<>("itemstack", itemstack))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Food;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class GoldFishItemItem extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:gold_fish_item")
|
||||
public static final Item block = null;
|
||||
|
||||
public GoldFishItemItem(HemModElements instance) {
|
||||
super(instance, 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new ItemCustom());
|
||||
}
|
||||
|
||||
public static class ItemCustom extends Item {
|
||||
public ItemCustom() {
|
||||
super(new Item.Properties().group(BlueleafTabItemGroup.tab).maxStackSize(64).rarity(Rarity.COMMON)
|
||||
.food((new Food.Builder()).hunger(1).saturation(0.3f)
|
||||
|
||||
.meat().build()));
|
||||
setRegistryName("gold_fish_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack itemstack, World world, LivingEntity entity) {
|
||||
ItemStack retval = new ItemStack(Items.BONE);
|
||||
super.onItemUseFinish(itemstack, world, entity);
|
||||
if (itemstack.isEmpty()) {
|
||||
return retval;
|
||||
} else {
|
||||
if (entity instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
if (!player.isCreative() && !player.inventory.addItemStackToInventory(retval))
|
||||
player.dropItem(retval, false);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.procedures.HotAirBalloonItemRightclickedOnBlockProcedure;
|
||||
import studio.halbear.hem.itemgroup.HalsExplorationModTechItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class HotAirBalloonItemItem extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:hot_air_balloon_item")
|
||||
public static final Item block = null;
|
||||
|
||||
public HotAirBalloonItemItem(HemModElements instance) {
|
||||
super(instance, 277);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new ItemCustom());
|
||||
}
|
||||
|
||||
public static class ItemCustom extends Item {
|
||||
public ItemCustom() {
|
||||
super(new Item.Properties().group(HalsExplorationModTechItemGroup.tab).maxStackSize(1).rarity(Rarity.COMMON));
|
||||
setRegistryName("hot_air_balloon_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
ActionResultType retval = super.onItemUseFirst(stack, context);
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
PlayerEntity entity = context.getPlayer();
|
||||
Direction direction = context.getFace();
|
||||
BlockState blockstate = world.getBlockState(pos);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
ItemStack itemstack = context.getItem();
|
||||
|
||||
HotAirBalloonItemRightclickedOnBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("itemstack", itemstack))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.procedures.LadybugSpawnEggRightclickedOnBlockProcedure;
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class LadybugSpawnEggItem extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:ladybug_spawn_egg")
|
||||
public static final Item block = null;
|
||||
|
||||
public LadybugSpawnEggItem(HemModElements instance) {
|
||||
super(instance, 36);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new ItemCustom());
|
||||
}
|
||||
|
||||
public static class ItemCustom extends Item {
|
||||
public ItemCustom() {
|
||||
super(new Item.Properties().group(BlueleafTabItemGroup.tab).maxStackSize(64).rarity(Rarity.COMMON));
|
||||
setRegistryName("ladybug_spawn_egg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
ActionResultType retval = super.onItemUseFirst(stack, context);
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
PlayerEntity entity = context.getPlayer();
|
||||
Direction direction = context.getFace();
|
||||
BlockState blockstate = world.getBlockState(pos);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
ItemStack itemstack = context.getItem();
|
||||
|
||||
LadybugSpawnEggRightclickedOnBlockProcedure.executeProcedure(Stream
|
||||
.of(new AbstractMap.SimpleEntry<>("world", world), new AbstractMap.SimpleEntry<>("x", x), new AbstractMap.SimpleEntry<>("y", y),
|
||||
new AbstractMap.SimpleEntry<>("z", z), new AbstractMap.SimpleEntry<>("entity", entity),
|
||||
new AbstractMap.SimpleEntry<>("itemstack", itemstack))
|
||||
.collect(HashMap::new, (_m, _e) -> _m.put(_e.getKey(), _e.getValue()), Map::putAll));
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
|
||||
package studio.halbear.hem.item;
|
||||
|
||||
import studio.halbear.hem.itemgroup.BlueleafTabItemGroup;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Food;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class TigerFishItemItem extends HemModElements.ModElement {
|
||||
@ObjectHolder("hem:tiger_fish_item")
|
||||
public static final Item block = null;
|
||||
|
||||
public TigerFishItemItem(HemModElements instance) {
|
||||
super(instance, 53);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new ItemCustom());
|
||||
}
|
||||
|
||||
public static class ItemCustom extends Item {
|
||||
public ItemCustom() {
|
||||
super(new Item.Properties().group(BlueleafTabItemGroup.tab).maxStackSize(64).rarity(Rarity.COMMON)
|
||||
.food((new Food.Builder()).hunger(3).saturation(1.5f)
|
||||
|
||||
.meat().build()));
|
||||
setRegistryName("tiger_fish_item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack par1ItemStack, BlockState par2Block) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack itemstack, World world, LivingEntity entity) {
|
||||
ItemStack retval = new ItemStack(Items.BONE);
|
||||
super.onItemUseFinish(itemstack, world, entity);
|
||||
if (itemstack.isEmpty()) {
|
||||
return retval;
|
||||
} else {
|
||||
if (entity instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
if (!player.isCreative() && !player.inventory.addItemStackToInventory(retval))
|
||||
player.dropItem(retval, false);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
package studio.halbear.hem.itemgroup;
|
||||
|
||||
import studio.halbear.hem.block.BlueleafGrassBlockBlock;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class BlueleafTabItemGroup extends HemModElements.ModElement {
|
||||
public BlueleafTabItemGroup(HemModElements instance) {
|
||||
super(instance, 63);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
tab = new ItemGroup("tabblueleaf_tab") {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
return new ItemStack(BlueleafGrassBlockBlock.block);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean hasSearchBar() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static ItemGroup tab;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
package studio.halbear.hem.itemgroup;
|
||||
|
||||
import studio.halbear.hem.item.HotAirBalloonItemItem;
|
||||
import studio.halbear.hem.HemModElements;
|
||||
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
|
||||
@HemModElements.ModElement.Tag
|
||||
public class HalsExplorationModTechItemGroup extends HemModElements.ModElement {
|
||||
public HalsExplorationModTechItemGroup(HemModElements instance) {
|
||||
super(instance, 290);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
tab = new ItemGroup("tabhals_exploration_mod_tech") {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
return new ItemStack(HotAirBalloonItemItem.block);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean hasSearchBar() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static ItemGroup tab;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user