mirror of
https://github.com/nimsolated/Nims-Random-BS.git
synced 2026-04-02 10:20:42 -07:00
fix: source code
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package net.mcreator.nimsrandombullshit;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.util.thread.SidedThreadGroups;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModTabs;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMobEffects;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModItems;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEntities;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEnchantments;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlocks;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlockEntities;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@Mod("nims_random_bullshit")
|
||||
public class NimsRandomBullshitMod {
|
||||
public static final Logger LOGGER = LogManager.getLogger(NimsRandomBullshitMod.class);
|
||||
public static final String MODID = "nims_random_bullshit";
|
||||
|
||||
public NimsRandomBullshitMod() {
|
||||
// Start of user code block mod constructor
|
||||
// End of user code block mod constructor
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
NimsRandomBullshitModBlocks.REGISTRY.register(bus);
|
||||
NimsRandomBullshitModBlockEntities.REGISTRY.register(bus);
|
||||
NimsRandomBullshitModItems.REGISTRY.register(bus);
|
||||
NimsRandomBullshitModEntities.REGISTRY.register(bus);
|
||||
NimsRandomBullshitModEnchantments.REGISTRY.register(bus);
|
||||
NimsRandomBullshitModTabs.REGISTRY.register(bus);
|
||||
|
||||
NimsRandomBullshitModMobEffects.REGISTRY.register(bus);
|
||||
|
||||
NimsRandomBullshitModMenus.REGISTRY.register(bus);
|
||||
|
||||
// Start of user code block mod init
|
||||
// End of user code block mod init
|
||||
}
|
||||
|
||||
// Start of user code block mod methods
|
||||
// End of user code block mod methods
|
||||
private static final String PROTOCOL_VERSION = "1";
|
||||
public static final SimpleChannel PACKET_HANDLER = NetworkRegistry.newSimpleChannel(new ResourceLocation(MODID, MODID), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
|
||||
private static int messageID = 0;
|
||||
|
||||
public static <T> void addNetworkMessage(Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, BiConsumer<T, Supplier<NetworkEvent.Context>> messageConsumer) {
|
||||
PACKET_HANDLER.registerMessage(messageID, messageType, encoder, decoder, messageConsumer);
|
||||
messageID++;
|
||||
}
|
||||
|
||||
private static final Collection<AbstractMap.SimpleEntry<Runnable, Integer>> workQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public static void queueServerWork(int tick, Runnable action) {
|
||||
if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER)
|
||||
workQueue.add(new AbstractMap.SimpleEntry<>(action, tick));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tick(TickEvent.ServerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
List<AbstractMap.SimpleEntry<Runnable, Integer>> actions = new ArrayList<>();
|
||||
workQueue.forEach(work -> {
|
||||
work.setValue(work.getValue() - 1);
|
||||
if (work.getValue() == 0)
|
||||
actions.add(work);
|
||||
});
|
||||
actions.forEach(e -> e.getKey().run());
|
||||
workQueue.removeAll(actions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class BrokenGlassBlock extends IronBarsBlock {
|
||||
public BrokenGlassBlock() {
|
||||
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.HAT).sound(SoundType.GLASS).strength(0.3f).noOcclusion().isRedstoneConductor((bs, br, bp) -> false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class CondensedCondensedCondensedNetherrackBlock extends Block {
|
||||
public CondensedCondensedCondensedNetherrackBlock() {
|
||||
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.NETHERRACK).strength(291.6f).requiresCorrectToolForDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class CondensedCondensedNetherrackBlock extends Block {
|
||||
public CondensedCondensedNetherrackBlock() {
|
||||
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.NETHERRACK).strength(32.4f).requiresCorrectToolForDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class CondensedNetherrackBlock extends Block {
|
||||
public CondensedNetherrackBlock() {
|
||||
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.NETHERRACK).strength(3.6f).requiresCorrectToolForDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class HexaCondensedNetherrackBlock extends Block {
|
||||
public HexaCondensedNetherrackBlock() {
|
||||
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.NETHERRACK).strength(64000f).requiresCorrectToolForDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.block.entity.OreMinerBlockEntity;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class OreMinerBlock extends Block implements EntityBlock {
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
|
||||
public OreMinerBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(1f, 100f));
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return super.getStateForPlacement(context).setValue(FACING, context.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
return state.setValue(FACING, rot.rotate(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState blockstate, Level world, BlockPos pos, Player entity, InteractionHand hand, BlockHitResult hit) {
|
||||
super.use(blockstate, world, pos, entity, hand, hit);
|
||||
if (entity instanceof ServerPlayer player) {
|
||||
NetworkHooks.openScreen(player, new MenuProvider() {
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.literal("Ore Miner");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
|
||||
return new OreMinerGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(pos));
|
||||
}
|
||||
}, pos);
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuProvider getMenuProvider(BlockState state, Level worldIn, BlockPos pos) {
|
||||
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
|
||||
return tileEntity instanceof MenuProvider menuProvider ? menuProvider : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new OreMinerBlockEntity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int eventID, int eventParam) {
|
||||
super.triggerEvent(state, world, pos, eventID, eventParam);
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
return blockEntity == null ? false : blockEntity.triggerEvent(eventID, eventParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof OreMinerBlockEntity be) {
|
||||
Containers.dropContents(world, pos, be);
|
||||
world.updateNeighbourForOutputSignal(pos, this);
|
||||
}
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnalogOutputSignal(BlockState blockState, Level world, BlockPos pos) {
|
||||
BlockEntity tileentity = world.getBlockEntity(pos);
|
||||
if (tileentity instanceof OreMinerBlockEntity be)
|
||||
return AbstractContainerMenu.getRedstoneSignalFromContainer(be);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class PentaCondensedNetherrackBlock extends Block {
|
||||
public PentaCondensedNetherrackBlock() {
|
||||
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.NETHERRACK).strength(23619.6f).requiresCorrectToolForDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.block;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class QuadraCondensedNetherrackBlock extends Block {
|
||||
public QuadraCondensedNetherrackBlock() {
|
||||
super(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).sound(SoundType.NETHERRACK).strength(2624.4f).requiresCorrectToolForDrops());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package net.mcreator.nimsrandombullshit.block.entity;
|
||||
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.WorldlyContainer;
|
||||
import net.minecraft.world.ContainerHelper;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlockEntities;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class OreMinerBlockEntity extends RandomizableContainerBlockEntity implements WorldlyContainer {
|
||||
private NonNullList<ItemStack> stacks = NonNullList.<ItemStack>withSize(9, ItemStack.EMPTY);
|
||||
private final LazyOptional<? extends IItemHandler>[] handlers = SidedInvWrapper.create(this, Direction.values());
|
||||
|
||||
public OreMinerBlockEntity(BlockPos position, BlockState state) {
|
||||
super(NimsRandomBullshitModBlockEntities.ORE_MINER.get(), position, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compound) {
|
||||
super.load(compound);
|
||||
if (!this.tryLoadLootTable(compound))
|
||||
this.stacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
ContainerHelper.loadAllItems(compound, this.stacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag compound) {
|
||||
super.saveAdditional(compound);
|
||||
if (!this.trySaveLootTable(compound)) {
|
||||
ContainerHelper.saveAllItems(compound, this.stacks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
return ClientboundBlockEntityDataPacket.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getUpdateTag() {
|
||||
return this.saveWithFullMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
return stacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (ItemStack itemstack : this.stacks)
|
||||
if (!itemstack.isEmpty())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDefaultName() {
|
||||
return Component.literal("ore_miner");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inventory) {
|
||||
return new OreMinerGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(this.worldPosition));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.literal("Ore Miner");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getItems() {
|
||||
return this.stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> stacks) {
|
||||
this.stacks = stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceItem(int index, ItemStack stack) {
|
||||
if (index == 1)
|
||||
return false;
|
||||
if (index == 2)
|
||||
return false;
|
||||
if (index == 3)
|
||||
return false;
|
||||
if (index == 4)
|
||||
return false;
|
||||
if (index == 5)
|
||||
return false;
|
||||
if (index == 6)
|
||||
return false;
|
||||
if (index == 7)
|
||||
return false;
|
||||
if (index == 8)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(Direction side) {
|
||||
return IntStream.range(0, this.getContainerSize()).toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceItemThroughFace(int index, ItemStack stack, @Nullable Direction direction) {
|
||||
return this.canPlaceItem(index, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeItemThroughFace(int index, ItemStack stack, Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (!this.remove && facing != null && capability == ForgeCapabilities.ITEM_HANDLER)
|
||||
return handlers[facing.ordinal()].cast();
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
for (LazyOptional<? extends IItemHandler> handler : handlers)
|
||||
handler.invalidate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.mcreator.nimsrandombullshit.client.gui;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.procedures.OreMinerGUISlot0ImageDisplayConditionProcedure;
|
||||
import net.mcreator.nimsrandombullshit.network.OreMinerGUIButtonMessage;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
public class OreMinerGUIScreen extends AbstractContainerScreen<OreMinerGUIMenu> {
|
||||
private final static HashMap<String, Object> guistate = OreMinerGUIMenu.guistate;
|
||||
private final Level world;
|
||||
private final int x, y, z;
|
||||
private final Player entity;
|
||||
Button button_mine;
|
||||
|
||||
public OreMinerGUIScreen(OreMinerGUIMenu container, Inventory inventory, Component 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.imageWidth = 176;
|
||||
this.imageHeight = 166;
|
||||
}
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("nims_random_bullshit:textures/screens/ore_miner_gui.png");
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(guiGraphics);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(guiGraphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int gx, int gy) {
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
guiGraphics.blit(texture, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight, this.imageWidth, this.imageHeight);
|
||||
if (OreMinerGUISlot0ImageDisplayConditionProcedure.execute(entity)) {
|
||||
guiGraphics.blit(new ResourceLocation("nims_random_bullshit:textures/screens/diamond_pickaxe_blueprint.png"), this.leftPos + 31, this.topPos + 17, 0, 0, 16, 16, 16, 16);
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, int b, int c) {
|
||||
if (key == 256) {
|
||||
this.minecraft.player.closeContainer();
|
||||
return true;
|
||||
}
|
||||
return super.keyPressed(key, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
button_mine = Button.builder(Component.translatable("gui.nims_random_bullshit.ore_miner_gui.button_mine"), e -> {
|
||||
if (true) {
|
||||
NimsRandomBullshitMod.PACKET_HANDLER.sendToServer(new OreMinerGUIButtonMessage(0, x, y, z));
|
||||
OreMinerGUIButtonMessage.handleButtonAction(entity, 0, x, y, z);
|
||||
}
|
||||
}).bounds(this.leftPos + 15, this.topPos + 43, 46, 20).build();
|
||||
guistate.put("button:button_mine", button_mine);
|
||||
this.addRenderableWidget(button_mine);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.mcreator.nimsrandombullshit.client.gui;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
public class ShitGUIScreen extends AbstractContainerScreen<ShitGUIMenu> {
|
||||
private final static HashMap<String, Object> guistate = ShitGUIMenu.guistate;
|
||||
private final Level world;
|
||||
private final int x, y, z;
|
||||
private final Player entity;
|
||||
|
||||
public ShitGUIScreen(ShitGUIMenu container, Inventory inventory, Component 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.imageWidth = 176;
|
||||
this.imageHeight = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(guiGraphics);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(guiGraphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int gx, int gy) {
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
|
||||
guiGraphics.blit(new ResourceLocation("nims_random_bullshit:textures/screens/shit.png"), this.leftPos + -30, this.topPos + -38, 0, 0, 240, 240, 240, 240);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, int b, int c) {
|
||||
if (key == 256) {
|
||||
this.minecraft.player.closeContainer();
|
||||
return true;
|
||||
}
|
||||
return super.keyPressed(key, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.shit_gui.label_uh_ohh_stinky"), -121, -34, -52, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.client.renderer;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
|
||||
import net.minecraft.client.renderer.entity.HumanoidMobRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.model.geom.ModelLayers;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.entity.GhoulEntity;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public class GhoulRenderer extends HumanoidMobRenderer<GhoulEntity, HumanoidModel<GhoulEntity>> {
|
||||
public GhoulRenderer(EntityRendererProvider.Context context) {
|
||||
super(context, new HumanoidModel<GhoulEntity>(context.bakeLayer(ModelLayers.PLAYER)), 0.25f);
|
||||
this.addLayer(new HumanoidArmorLayer(this, new HumanoidModel(context.bakeLayer(ModelLayers.PLAYER_INNER_ARMOR)), new HumanoidModel(context.bakeLayer(ModelLayers.PLAYER_OUTER_ARMOR)), context.getModelManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scale(GhoulEntity entity, PoseStack poseStack, float f) {
|
||||
poseStack.scale(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureLocation(GhoulEntity entity) {
|
||||
return new ResourceLocation("nims_random_bullshit:textures/entities/ghoul.png");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.enchantment;
|
||||
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModItems;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NetherrackingEnchantmentEnchantment extends Enchantment {
|
||||
private static final EnchantmentCategory ENCHANTMENT_CATEGORY = EnchantmentCategory.create("nims_random_bullshit_netherracking_enchantment",
|
||||
item -> Ingredient.of(new ItemStack(NimsRandomBullshitModItems.NETHERRACKITE_PICKAXE.get())).test(new ItemStack(item)));
|
||||
|
||||
public NetherrackingEnchantmentEnchantment() {
|
||||
super(Enchantment.Rarity.RARE, ENCHANTMENT_CATEGORY, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level) {
|
||||
return 1 + level * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int level) {
|
||||
return 6 + level * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkCompatibility(Enchantment enchantment) {
|
||||
return super.checkCompatibility(enchantment) && !List.of(Enchantments.BLOCK_EFFICIENCY).contains(enchantment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.enchantment;
|
||||
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class PassiveIncomeEnchantmentEnchantment extends Enchantment {
|
||||
private static final EnchantmentCategory ENCHANTMENT_CATEGORY = EnchantmentCategory.create("nims_random_bullshit_passive_income_enchantment",
|
||||
item -> Ingredient.of(ItemTags.create(new ResourceLocation("enchantable/equippable"))).test(new ItemStack(item)));
|
||||
|
||||
public PassiveIncomeEnchantmentEnchantment() {
|
||||
super(Enchantment.Rarity.VERY_RARE, ENCHANTMENT_CATEGORY, new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level) {
|
||||
return 1 + level * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int level) {
|
||||
return 6 + level * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.entity;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.monster.ZombieVillager;
|
||||
import net.minecraft.world.entity.monster.Zombie;
|
||||
import net.minecraft.world.entity.monster.Spider;
|
||||
import net.minecraft.world.entity.monster.Skeleton;
|
||||
import net.minecraft.world.entity.monster.Pillager;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.entity.monster.EnderMan;
|
||||
import net.minecraft.world.entity.monster.Creeper;
|
||||
import net.minecraft.world.entity.monster.CaveSpider;
|
||||
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
|
||||
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal;
|
||||
import net.minecraft.world.entity.ai.goal.RandomStrollGoal;
|
||||
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
|
||||
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.MobType;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.GhoulThisEntityKillsAnotherOneProcedure;
|
||||
import net.mcreator.nimsrandombullshit.procedures.GhoulOnInitialEntitySpawnProcedure;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEntities;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GhoulEntity extends Monster {
|
||||
public GhoulEntity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(NimsRandomBullshitModEntities.GHOUL.get(), world);
|
||||
}
|
||||
|
||||
public GhoulEntity(EntityType<GhoulEntity> type, Level world) {
|
||||
super(type, world);
|
||||
setMaxUpStep(0.6f);
|
||||
xpReward = 0;
|
||||
setNoAi(false);
|
||||
setPersistenceRequired();
|
||||
refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal(this, Zombie.class, false, true));
|
||||
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, ZombieVillager.class, false, true));
|
||||
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Creeper.class, false, true));
|
||||
this.targetSelector.addGoal(4, new NearestAttackableTargetGoal(this, EnderMan.class, false, true));
|
||||
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal(this, Spider.class, false, true));
|
||||
this.targetSelector.addGoal(6, new NearestAttackableTargetGoal(this, CaveSpider.class, false, true));
|
||||
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal(this, Pillager.class, false, true));
|
||||
this.targetSelector.addGoal(8, new NearestAttackableTargetGoal(this, Skeleton.class, false, true));
|
||||
this.goalSelector.addGoal(9, new MeleeAttackGoal(this, 1.2, false) {
|
||||
@Override
|
||||
protected double getAttackReachSqr(LivingEntity entity) {
|
||||
return this.mob.getBbWidth() * this.mob.getBbWidth() + entity.getBbWidth();
|
||||
}
|
||||
});
|
||||
this.targetSelector.addGoal(10, new HurtByTargetGoal(this));
|
||||
this.goalSelector.addGoal(11, new RandomStrollGoal(this, 1));
|
||||
this.goalSelector.addGoal(12, new RandomLookAroundGoal(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobType getMobType() {
|
||||
return MobType.UNDEAD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWhenFarAway(double distanceToClosestPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMyRidingOffset() {
|
||||
return -0.35D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getAmbientSound() {
|
||||
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.wither_skeleton.ambient"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playStepSound(BlockPos pos, BlockState blockIn) {
|
||||
this.playSound(ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.wither_skeleton.step")), 0.15f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getHurtSound(DamageSource ds) {
|
||||
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.wither_skeleton.hurt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getDeathSound() {
|
||||
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.wither_skeleton.death"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hurt(DamageSource damagesource, float amount) {
|
||||
if (damagesource.is(DamageTypes.IN_FIRE))
|
||||
return false;
|
||||
if (damagesource.is(DamageTypes.FALL))
|
||||
return false;
|
||||
if (damagesource.is(DamageTypes.CACTUS))
|
||||
return false;
|
||||
if (damagesource.is(DamageTypes.DROWN))
|
||||
return false;
|
||||
if (damagesource.is(DamageTypes.WITHER) || damagesource.is(DamageTypes.WITHER_SKULL))
|
||||
return false;
|
||||
return super.hurt(damagesource, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fireImmune() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData livingdata, @Nullable CompoundTag tag) {
|
||||
SpawnGroupData retval = super.finalizeSpawn(world, difficulty, reason, livingdata, tag);
|
||||
GhoulOnInitialEntitySpawnProcedure.execute(this);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void awardKillScore(Entity entity, int score, DamageSource damageSource) {
|
||||
super.awardKillScore(entity, score, damageSource);
|
||||
GhoulThisEntityKillsAnotherOneProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDimensions getDimensions(Pose pose) {
|
||||
return super.getDimensions(pose).scale(0.5f);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
}
|
||||
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
AttributeSupplier.Builder builder = Mob.createMobAttributes();
|
||||
builder = builder.add(Attributes.MOVEMENT_SPEED, 0.36);
|
||||
builder = builder.add(Attributes.MAX_HEALTH, 9);
|
||||
builder = builder.add(Attributes.ARMOR, 0);
|
||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 3);
|
||||
builder = builder.add(Attributes.FOLLOW_RANGE, 19);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.entity;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.network.PlayMessages;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.projectile.ItemSupplier;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.ShitProjectileProjectileHitsPlayerProcedure;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModItems;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEntities;
|
||||
|
||||
@OnlyIn(value = Dist.CLIENT, _interface = ItemSupplier.class)
|
||||
public class ShitProjectileEntity extends AbstractArrow implements ItemSupplier {
|
||||
public static final ItemStack PROJECTILE_ITEM = new ItemStack(NimsRandomBullshitModItems.SHIT.get());
|
||||
|
||||
public ShitProjectileEntity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
super(NimsRandomBullshitModEntities.SHIT_PROJECTILE.get(), world);
|
||||
}
|
||||
|
||||
public ShitProjectileEntity(EntityType<? extends ShitProjectileEntity> type, Level world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public ShitProjectileEntity(EntityType<? extends ShitProjectileEntity> type, double x, double y, double z, Level world) {
|
||||
super(type, x, y, z, world);
|
||||
}
|
||||
|
||||
public ShitProjectileEntity(EntityType<? extends ShitProjectileEntity> type, LivingEntity entity, Level world) {
|
||||
super(type, entity, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public ItemStack getItem() {
|
||||
return PROJECTILE_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getPickupItem() {
|
||||
return PROJECTILE_ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPostHurtEffects(LivingEntity entity) {
|
||||
super.doPostHurtEffects(entity);
|
||||
entity.setArrowCount(entity.getArrowCount() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerTouch(Player entity) {
|
||||
super.playerTouch(entity);
|
||||
ShitProjectileProjectileHitsPlayerProcedure.execute(this.level(), this.getX(), this.getY(), this.getZ(), entity, this.getOwner());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.inGround)
|
||||
this.discard();
|
||||
}
|
||||
|
||||
public static ShitProjectileEntity shoot(Level world, LivingEntity entity, RandomSource source) {
|
||||
return shoot(world, entity, source, 1f, 0, 0);
|
||||
}
|
||||
|
||||
public static ShitProjectileEntity shoot(Level world, LivingEntity entity, RandomSource source, float pullingPower) {
|
||||
return shoot(world, entity, source, pullingPower * 1f, 0, 0);
|
||||
}
|
||||
|
||||
public static ShitProjectileEntity shoot(Level world, LivingEntity entity, RandomSource random, float power, double damage, int knockback) {
|
||||
ShitProjectileEntity entityarrow = new ShitProjectileEntity(NimsRandomBullshitModEntities.SHIT_PROJECTILE.get(), entity, world);
|
||||
entityarrow.shoot(entity.getViewVector(1).x, entity.getViewVector(1).y, entity.getViewVector(1).z, power * 2, 0);
|
||||
entityarrow.setSilent(true);
|
||||
entityarrow.setCritArrow(false);
|
||||
entityarrow.setBaseDamage(damage);
|
||||
entityarrow.setKnockback(knockback);
|
||||
world.addFreshEntity(entityarrow);
|
||||
world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.snowball.throw")), SoundSource.PLAYERS, 1, 1f / (random.nextFloat() * 0.5f + 1) + (power / 2));
|
||||
return entityarrow;
|
||||
}
|
||||
|
||||
public static ShitProjectileEntity shoot(LivingEntity entity, LivingEntity target) {
|
||||
ShitProjectileEntity entityarrow = new ShitProjectileEntity(NimsRandomBullshitModEntities.SHIT_PROJECTILE.get(), entity, entity.level());
|
||||
double dx = target.getX() - entity.getX();
|
||||
double dy = target.getY() + target.getEyeHeight() - 1.1;
|
||||
double dz = target.getZ() - entity.getZ();
|
||||
entityarrow.shoot(dx, dy - entityarrow.getY() + Math.hypot(dx, dz) * 0.2F, dz, 1f * 2, 12.0F);
|
||||
entityarrow.setSilent(true);
|
||||
entityarrow.setBaseDamage(0);
|
||||
entityarrow.setKnockback(0);
|
||||
entityarrow.setCritArrow(false);
|
||||
entity.level().addFreshEntity(entityarrow);
|
||||
entity.level().playSound(null, entity.getX(), entity.getY(), entity.getZ(), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.snowball.throw")), SoundSource.PLAYERS, 1, 1f / (RandomSource.create().nextFloat() * 0.5f + 1));
|
||||
return entityarrow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.block.entity.OreMinerBlockEntity;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModBlockEntities {
|
||||
public static final DeferredRegister<BlockEntityType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<BlockEntityType<?>> ORE_MINER = register("ore_miner", NimsRandomBullshitModBlocks.ORE_MINER, OreMinerBlockEntity::new);
|
||||
|
||||
// Start of user code block custom block entities
|
||||
// End of user code block custom block entities
|
||||
private static RegistryObject<BlockEntityType<?>> register(String registryname, RegistryObject<Block> block, BlockEntityType.BlockEntitySupplier<?> supplier) {
|
||||
return REGISTRY.register(registryname, () -> BlockEntityType.Builder.of(supplier, block.get()).build(null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.block.QuadraCondensedNetherrackBlock;
|
||||
import net.mcreator.nimsrandombullshit.block.PentaCondensedNetherrackBlock;
|
||||
import net.mcreator.nimsrandombullshit.block.OreMinerBlock;
|
||||
import net.mcreator.nimsrandombullshit.block.HexaCondensedNetherrackBlock;
|
||||
import net.mcreator.nimsrandombullshit.block.CondensedNetherrackBlock;
|
||||
import net.mcreator.nimsrandombullshit.block.CondensedCondensedNetherrackBlock;
|
||||
import net.mcreator.nimsrandombullshit.block.CondensedCondensedCondensedNetherrackBlock;
|
||||
import net.mcreator.nimsrandombullshit.block.BrokenGlassBlock;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModBlocks {
|
||||
public static final DeferredRegister<Block> REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<Block> CONDENSED_NETHERRACK = REGISTRY.register("condensed_netherrack", () -> new CondensedNetherrackBlock());
|
||||
public static final RegistryObject<Block> CONDENSED_CONDENSED_NETHERRACK = REGISTRY.register("condensed_condensed_netherrack", () -> new CondensedCondensedNetherrackBlock());
|
||||
public static final RegistryObject<Block> CONDENSED_CONDENSED_CONDENSED_NETHERRACK = REGISTRY.register("condensed_condensed_condensed_netherrack", () -> new CondensedCondensedCondensedNetherrackBlock());
|
||||
public static final RegistryObject<Block> BROKEN_GLASS = REGISTRY.register("broken_glass", () -> new BrokenGlassBlock());
|
||||
public static final RegistryObject<Block> QUADRA_CONDENSED_NETHERRACK = REGISTRY.register("quadra_condensed_netherrack", () -> new QuadraCondensedNetherrackBlock());
|
||||
public static final RegistryObject<Block> PENTA_CONDENSED_NETHERRACK = REGISTRY.register("penta_condensed_netherrack", () -> new PentaCondensedNetherrackBlock());
|
||||
public static final RegistryObject<Block> HEXA_CONDENSED_NETHERRACK = REGISTRY.register("hexa_condensed_netherrack", () -> new HexaCondensedNetherrackBlock());
|
||||
public static final RegistryObject<Block> ORE_MINER = REGISTRY.register("ore_miner", () -> new OreMinerBlock());
|
||||
// Start of user code block custom blocks
|
||||
// End of user code block custom blocks
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.enchantment.PassiveIncomeEnchantmentEnchantment;
|
||||
import net.mcreator.nimsrandombullshit.enchantment.NetherrackingEnchantmentEnchantment;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModEnchantments {
|
||||
public static final DeferredRegister<Enchantment> REGISTRY = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<Enchantment> PASSIVE_INCOME_ENCHANTMENT = REGISTRY.register("passive_income_enchantment", () -> new PassiveIncomeEnchantmentEnchantment());
|
||||
public static final RegistryObject<Enchantment> NETHERRACKING_ENCHANTMENT = REGISTRY.register("netherracking_enchantment", () -> new NetherrackingEnchantmentEnchantment());
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.entity.ShitProjectileEntity;
|
||||
import net.mcreator.nimsrandombullshit.entity.GhoulEntity;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class NimsRandomBullshitModEntities {
|
||||
public static final DeferredRegister<EntityType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<EntityType<ShitProjectileEntity>> SHIT_PROJECTILE = register("shit_projectile",
|
||||
EntityType.Builder.<ShitProjectileEntity>of(ShitProjectileEntity::new, MobCategory.MISC).setCustomClientFactory(ShitProjectileEntity::new).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(1).sized(0.5f, 0.5f));
|
||||
public static final RegistryObject<EntityType<GhoulEntity>> GHOUL = register("ghoul",
|
||||
EntityType.Builder.<GhoulEntity>of(GhoulEntity::new, MobCategory.MONSTER).setShouldReceiveVelocityUpdates(true).setTrackingRange(64).setUpdateInterval(3).setCustomClientFactory(GhoulEntity::new).fireImmune().sized(0.6f, 1.8f));
|
||||
|
||||
// Start of user code block custom entities
|
||||
// End of user code block custom entities
|
||||
private static <T extends Entity> RegistryObject<EntityType<T>> register(String registryname, EntityType.Builder<T> entityTypeBuilder) {
|
||||
return REGISTRY.register(registryname, () -> (EntityType<T>) entityTypeBuilder.build(registryname));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void init(FMLCommonSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
GhoulEntity.init();
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerAttributes(EntityAttributeCreationEvent event) {
|
||||
event.put(GHOUL.get(), GhoulEntity.createAttributes().build());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.client.renderer.entity.ThrownItemRenderer;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.client.renderer.GhoulRenderer;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public class NimsRandomBullshitModEntityRenderers {
|
||||
@SubscribeEvent
|
||||
public static void registerEntityRenderers(EntityRenderersEvent.RegisterRenderers event) {
|
||||
event.registerEntityRenderer(NimsRandomBullshitModEntities.SHIT_PROJECTILE.get(), ThrownItemRenderer::new);
|
||||
event.registerEntityRenderer(NimsRandomBullshitModEntities.GHOUL.get(), GhoulRenderer::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.item.ShitItem;
|
||||
import net.mcreator.nimsrandombullshit.item.SandDustItem;
|
||||
import net.mcreator.nimsrandombullshit.item.NetherrackitePickaxeItem;
|
||||
import net.mcreator.nimsrandombullshit.item.NetherrackiteItem;
|
||||
import net.mcreator.nimsrandombullshit.item.MagicFleshItem;
|
||||
import net.mcreator.nimsrandombullshit.item.MagicDustItem;
|
||||
import net.mcreator.nimsrandombullshit.item.LapisLazuliNuggetItem;
|
||||
import net.mcreator.nimsrandombullshit.item.GravediggerItem;
|
||||
import net.mcreator.nimsrandombullshit.item.GoldenBerriesItem;
|
||||
import net.mcreator.nimsrandombullshit.item.BlockEaterItem;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModItems {
|
||||
public static final DeferredRegister<Item> REGISTRY = DeferredRegister.create(ForgeRegistries.ITEMS, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<Item> CONDENSED_NETHERRACK = block(NimsRandomBullshitModBlocks.CONDENSED_NETHERRACK);
|
||||
public static final RegistryObject<Item> CONDENSED_CONDENSED_NETHERRACK = block(NimsRandomBullshitModBlocks.CONDENSED_CONDENSED_NETHERRACK);
|
||||
public static final RegistryObject<Item> CONDENSED_CONDENSED_CONDENSED_NETHERRACK = block(NimsRandomBullshitModBlocks.CONDENSED_CONDENSED_CONDENSED_NETHERRACK);
|
||||
public static final RegistryObject<Item> BLOCK_EATER = REGISTRY.register("block_eater", () -> new BlockEaterItem());
|
||||
public static final RegistryObject<Item> BROKEN_GLASS = block(NimsRandomBullshitModBlocks.BROKEN_GLASS);
|
||||
public static final RegistryObject<Item> QUADRA_CONDENSED_NETHERRACK = block(NimsRandomBullshitModBlocks.QUADRA_CONDENSED_NETHERRACK);
|
||||
public static final RegistryObject<Item> NETHERRACKITE_PICKAXE = REGISTRY.register("netherrackite_pickaxe", () -> new NetherrackitePickaxeItem());
|
||||
public static final RegistryObject<Item> NETHERRACKITE = REGISTRY.register("netherrackite", () -> new NetherrackiteItem());
|
||||
public static final RegistryObject<Item> PENTA_CONDENSED_NETHERRACK = block(NimsRandomBullshitModBlocks.PENTA_CONDENSED_NETHERRACK);
|
||||
public static final RegistryObject<Item> HEXA_CONDENSED_NETHERRACK = block(NimsRandomBullshitModBlocks.HEXA_CONDENSED_NETHERRACK);
|
||||
public static final RegistryObject<Item> SAND_DUST = REGISTRY.register("sand_dust", () -> new SandDustItem());
|
||||
public static final RegistryObject<Item> LAPIS_LAZULI_NUGGET = REGISTRY.register("lapis_lazuli_nugget", () -> new LapisLazuliNuggetItem());
|
||||
public static final RegistryObject<Item> MAGIC_DUST = REGISTRY.register("magic_dust", () -> new MagicDustItem());
|
||||
public static final RegistryObject<Item> MAGIC_FLESH = REGISTRY.register("magic_flesh", () -> new MagicFleshItem());
|
||||
public static final RegistryObject<Item> SHIT = REGISTRY.register("shit", () -> new ShitItem());
|
||||
public static final RegistryObject<Item> GOLDEN_BERRIES = REGISTRY.register("golden_berries", () -> new GoldenBerriesItem());
|
||||
public static final RegistryObject<Item> ORE_MINER = block(NimsRandomBullshitModBlocks.ORE_MINER);
|
||||
public static final RegistryObject<Item> GHOUL_SPAWN_EGG = REGISTRY.register("ghoul_spawn_egg", () -> new ForgeSpawnEggItem(NimsRandomBullshitModEntities.GHOUL, -16777216, -13421773, new Item.Properties()));
|
||||
public static final RegistryObject<Item> GRAVEDIGGER = REGISTRY.register("gravedigger", () -> new GravediggerItem());
|
||||
|
||||
// Start of user code block custom items
|
||||
// End of user code block custom items
|
||||
private static RegistryObject<Item> block(RegistryObject<Block> block) {
|
||||
return REGISTRY.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModMenus {
|
||||
public static final DeferredRegister<MenuType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.MENU_TYPES, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<MenuType<ShitGUIMenu>> SHIT_GUI = REGISTRY.register("shit_gui", () -> IForgeMenuType.create(ShitGUIMenu::new));
|
||||
public static final RegistryObject<MenuType<OreMinerGUIMenu>> ORE_MINER_GUI = REGISTRY.register("ore_miner_gui", () -> IForgeMenuType.create(OreMinerGUIMenu::new));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.potion.SummonedEntityEffectMobEffect;
|
||||
import net.mcreator.nimsrandombullshit.potion.StinkyEffectMobEffect;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModMobEffects {
|
||||
public static final DeferredRegister<MobEffect> REGISTRY = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<MobEffect> STINKY_EFFECT = REGISTRY.register("stinky_effect", () -> new StinkyEffectMobEffect());
|
||||
public static final RegistryObject<MobEffect> SUMMONED_ENTITY_EFFECT = REGISTRY.register("summoned_entity_effect", () -> new SummonedEntityEffectMobEffect());
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.client.gui.ShitGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.OreMinerGUIScreen;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public class NimsRandomBullshitModScreens {
|
||||
@SubscribeEvent
|
||||
public static void clientLoad(FMLClientSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.SHIT_GUI.get(), ShitGUIScreen::new);
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.ORE_MINER_GUI.get(), OreMinerGUIScreen::new);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class NimsRandomBullshitModTabs {
|
||||
public static final DeferredRegister<CreativeModeTab> REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, NimsRandomBullshitMod.MODID);
|
||||
|
||||
@SubscribeEvent
|
||||
public static void buildTabContentsVanilla(BuildCreativeModeTabContentsEvent tabData) {
|
||||
if (tabData.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS) {
|
||||
tabData.accept(NimsRandomBullshitModBlocks.CONDENSED_NETHERRACK.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.CONDENSED_CONDENSED_NETHERRACK.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.CONDENSED_CONDENSED_CONDENSED_NETHERRACK.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.BROKEN_GLASS.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.QUADRA_CONDENSED_NETHERRACK.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.PENTA_CONDENSED_NETHERRACK.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.HEXA_CONDENSED_NETHERRACK.get().asItem());
|
||||
} else if (tabData.getTabKey() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
||||
tabData.accept(NimsRandomBullshitModItems.BLOCK_EATER.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.NETHERRACKITE_PICKAXE.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.SHIT.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.GRAVEDIGGER.get());
|
||||
} else if (tabData.getTabKey() == CreativeModeTabs.INGREDIENTS) {
|
||||
tabData.accept(NimsRandomBullshitModItems.NETHERRACKITE.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.SAND_DUST.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.LAPIS_LAZULI_NUGGET.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.MAGIC_DUST.get());
|
||||
} else if (tabData.getTabKey() == CreativeModeTabs.FOOD_AND_DRINKS) {
|
||||
tabData.accept(NimsRandomBullshitModItems.MAGIC_FLESH.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.GOLDEN_BERRIES.get());
|
||||
} else if (tabData.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) {
|
||||
tabData.accept(NimsRandomBullshitModBlocks.ORE_MINER.get().asItem());
|
||||
} else if (tabData.getTabKey() == CreativeModeTabs.SPAWN_EGGS) {
|
||||
tabData.accept(NimsRandomBullshitModItems.GHOUL_SPAWN_EGG.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.item.UseAnim;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.BlockEaterRightclickedOnBlockProcedure;
|
||||
|
||||
public class BlockEaterItem extends Item {
|
||||
public BlockEaterItem() {
|
||||
super(new Item.Properties().stacksTo(1).rarity(Rarity.EPIC));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAnim getUseAnimation(ItemStack itemstack) {
|
||||
return UseAnim.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
super.useOn(context);
|
||||
BlockEaterRightclickedOnBlockProcedure.execute(context.getLevel(), context.getClickedPos().getX(), context.getClickedPos().getY(), context.getClickedPos().getZ(), context.getPlayer(), context.getItemInHand());
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
|
||||
public class GoldenBerriesItem extends Item {
|
||||
public GoldenBerriesItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.UNCOMMON).food((new FoodProperties.Builder()).nutrition(4).saturationMod(12f).build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack itemstack) {
|
||||
return 24;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.GravediggerRightclickedOnBlockProcedure;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GravediggerItem extends ShovelItem {
|
||||
public GravediggerItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return 3666;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return 4f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return 2f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(Items.WITHER_SKELETON_SKULL));
|
||||
}
|
||||
}, 1, -3f, new Item.Properties().fireResistant());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level level, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, level, list, flag);
|
||||
list.add(Component.translatable("item.nims_random_bullshit.gravedigger.description_0"));
|
||||
list.add(Component.translatable("item.nims_random_bullshit.gravedigger.description_1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
super.useOn(context);
|
||||
GravediggerRightclickedOnBlockProcedure.execute(context.getLevel(), context.getClickedPos().getX(), context.getClickedPos().getY(), context.getClickedPos().getZ(), context.getLevel().getBlockState(context.getClickedPos()),
|
||||
context.getPlayer(), context.getItemInHand());
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class LapisLazuliNuggetItem extends Item {
|
||||
public LapisLazuliNuggetItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class MagicDustItem extends Item {
|
||||
public MagicDustItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.MagicFleshOnPlayerStoppedUsingProcedure;
|
||||
|
||||
public class MagicFleshItem extends Item {
|
||||
public MagicFleshItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.UNCOMMON).food((new FoodProperties.Builder()).nutrition(4).saturationMod(0.2f).alwaysEat().build()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack itemstack) {
|
||||
return 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack finishUsingItem(ItemStack itemstack, Level world, LivingEntity entity) {
|
||||
ItemStack retval = super.finishUsingItem(itemstack, world, entity);
|
||||
double x = entity.getX();
|
||||
double y = entity.getY();
|
||||
double z = entity.getZ();
|
||||
MagicFleshOnPlayerStoppedUsingProcedure.execute(world, x, y, z);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class NetherrackiteItem extends Item {
|
||||
public NetherrackiteItem() {
|
||||
super(new Item.Properties().stacksTo(64).fireResistant().rarity(Rarity.RARE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.NetherrackitePickaxeBlockDestroyedWithToolProcedure;
|
||||
import net.mcreator.nimsrandombullshit.procedures.NetherrackingLogicProcedure;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NetherrackitePickaxeItem extends PickaxeItem {
|
||||
public NetherrackitePickaxeItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return 18279;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return 729f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return 2f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of();
|
||||
}
|
||||
}, 1, -3f, new Item.Properties().fireResistant());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mineBlock(ItemStack itemstack, Level world, BlockState blockstate, BlockPos pos, LivingEntity entity) {
|
||||
boolean retval = super.mineBlock(itemstack, world, blockstate, pos, entity);
|
||||
NetherrackitePickaxeBlockDestroyedWithToolProcedure.execute(world, pos.getX(), pos.getY(), pos.getZ(), blockstate);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level level, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, level, list, flag);
|
||||
list.add(Component.translatable("item.nims_random_bullshit.netherrackite_pickaxe.description_0"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
||||
super.inventoryTick(itemstack, world, entity, slot, selected);
|
||||
if (selected)
|
||||
NetherrackingLogicProcedure.execute(world, entity, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class SandDustItem extends Item {
|
||||
public SandDustItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.UseAnim;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.ProjectileWeaponItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.BowItem;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.entity.ShitProjectileEntity;
|
||||
|
||||
public class ShitItem extends Item {
|
||||
public ShitItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAnim getUseAnimation(ItemStack itemstack) {
|
||||
return UseAnim.SPEAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack itemstack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = InteractionResultHolder.fail(entity.getItemInHand(hand));
|
||||
if (entity.getAbilities().instabuild || findAmmo(entity) != ItemStack.EMPTY) {
|
||||
ar = InteractionResultHolder.success(entity.getItemInHand(hand));
|
||||
entity.startUsingItem(hand);
|
||||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseUsing(ItemStack itemstack, Level world, LivingEntity entity, int time) {
|
||||
if (!world.isClientSide() && entity instanceof ServerPlayer player) {
|
||||
float pullingPower = BowItem.getPowerForTime(this.getUseDuration(itemstack) - time);
|
||||
if (pullingPower < 0.1)
|
||||
return;
|
||||
ItemStack stack = findAmmo(player);
|
||||
if (player.getAbilities().instabuild || stack != ItemStack.EMPTY) {
|
||||
ShitProjectileEntity projectile = ShitProjectileEntity.shoot(world, entity, world.getRandom(), pullingPower);
|
||||
if (player.getAbilities().instabuild) {
|
||||
projectile.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
|
||||
} else {
|
||||
if (stack.isDamageableItem()) {
|
||||
if (stack.hurt(1, world.getRandom(), player)) {
|
||||
stack.shrink(1);
|
||||
stack.setDamageValue(0);
|
||||
if (stack.isEmpty())
|
||||
player.getInventory().removeItem(stack);
|
||||
}
|
||||
} else {
|
||||
stack.shrink(1);
|
||||
if (stack.isEmpty())
|
||||
player.getInventory().removeItem(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack findAmmo(Player player) {
|
||||
ItemStack stack = ProjectileWeaponItem.getHeldProjectile(player, e -> e.getItem() == ShitProjectileEntity.PROJECTILE_ITEM.getItem());
|
||||
if (stack == ItemStack.EMPTY) {
|
||||
for (int i = 0; i < player.getInventory().items.size(); i++) {
|
||||
ItemStack teststack = player.getInventory().items.get(i);
|
||||
if (teststack != null && teststack.getItem() == ShitProjectileEntity.PROJECTILE_ITEM.getItem()) {
|
||||
stack = teststack;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.network;
|
||||
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.procedures.OreMinerMineButtonPressedProcedure;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class OreMinerGUIButtonMessage {
|
||||
private final int buttonID, x, y, z;
|
||||
|
||||
public OreMinerGUIButtonMessage(FriendlyByteBuf buffer) {
|
||||
this.buttonID = buffer.readInt();
|
||||
this.x = buffer.readInt();
|
||||
this.y = buffer.readInt();
|
||||
this.z = buffer.readInt();
|
||||
}
|
||||
|
||||
public OreMinerGUIButtonMessage(int buttonID, int x, int y, int z) {
|
||||
this.buttonID = buttonID;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static void buffer(OreMinerGUIButtonMessage message, FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(message.buttonID);
|
||||
buffer.writeInt(message.x);
|
||||
buffer.writeInt(message.y);
|
||||
buffer.writeInt(message.z);
|
||||
}
|
||||
|
||||
public static void handler(OreMinerGUIButtonMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
Player 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 void handleButtonAction(Player entity, int buttonID, int x, int y, int z) {
|
||||
Level world = entity.level();
|
||||
HashMap guistate = OreMinerGUIMenu.guistate;
|
||||
// security measure to prevent arbitrary chunk generation
|
||||
if (!world.hasChunkAt(new BlockPos(x, y, z)))
|
||||
return;
|
||||
if (buttonID == 0) {
|
||||
|
||||
OreMinerMineButtonPressedProcedure.execute(world, x, y, z, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerMessage(FMLCommonSetupEvent event) {
|
||||
NimsRandomBullshitMod.addNetworkMessage(OreMinerGUIButtonMessage.class, OreMinerGUIButtonMessage::buffer, OreMinerGUIButtonMessage::new, OreMinerGUIButtonMessage::handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.potion;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeMap;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.StinkyEffectOnEffectActiveTickProcedure;
|
||||
import net.mcreator.nimsrandombullshit.procedures.StinkyEffectEffectExpiresProcedure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StinkyEffectMobEffect extends MobEffect {
|
||||
public StinkyEffectMobEffect() {
|
||||
super(MobEffectCategory.HARMFUL, -2621555);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getCurativeItems() {
|
||||
ArrayList<ItemStack> cures = new ArrayList<ItemStack>();
|
||||
return cures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyEffectTick(LivingEntity entity, int amplifier) {
|
||||
StinkyEffectOnEffectActiveTickProcedure.execute(entity.level(), entity.getX(), entity.getY(), entity.getZ(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttributeModifiers(LivingEntity entity, AttributeMap attributeMap, int amplifier) {
|
||||
super.removeAttributeModifiers(entity, attributeMap, amplifier);
|
||||
StinkyEffectEffectExpiresProcedure.execute(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDurationEffectTick(int duration, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.potion;
|
||||
|
||||
import net.minecraftforge.client.extensions.common.IClientMobEffectExtensions;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeMap;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.SummonedEntityEffectEffectExpiresProcedure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SummonedEntityEffectMobEffect extends MobEffect {
|
||||
public SummonedEntityEffectMobEffect() {
|
||||
super(MobEffectCategory.HARMFUL, -16777216);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getCurativeItems() {
|
||||
ArrayList<ItemStack> cures = new ArrayList<ItemStack>();
|
||||
return cures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttributeModifiers(LivingEntity entity, AttributeMap attributeMap, int amplifier) {
|
||||
super.removeAttributeModifiers(entity, attributeMap, amplifier);
|
||||
SummonedEntityEffectEffectExpiresProcedure.execute(entity.level(), entity.getX(), entity.getY(), entity.getZ(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDurationEffectTick(int duration, int amplifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeClient(java.util.function.Consumer<IClientMobEffectExtensions> consumer) {
|
||||
consumer.accept(new IClientMobEffectExtensions() {
|
||||
@Override
|
||||
public boolean isVisibleInInventory(MobEffectInstance effect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInventoryText(MobEffectInstance instance, EffectRenderingInventoryScreen<?> screen, GuiGraphics guiGraphics, int x, int y, int blitOffset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInGui(MobEffectInstance effect) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class BlockEaterRightclickedOnBlockProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (world.getBlockState(BlockPos.containing(x, y, z)).getDestroySpeed(world, BlockPos.containing(x, y, z)) != -1) {
|
||||
world.setBlock(BlockPos.containing(x, y, z), Blocks.AIR.defaultBlockState(), 3);
|
||||
if (entity instanceof Player _player)
|
||||
_player.getFoodData().setFoodLevel((int) ((entity instanceof Player _plr ? _plr.getFoodData().getFoodLevel() : 0) + 4));
|
||||
if ((entity instanceof Player _plr ? _plr.getFoodData().getFoodLevel() : 0) >= 20) {
|
||||
if (entity instanceof Player _player)
|
||||
_player.getFoodData().setSaturation((float) ((entity instanceof Player _plr ? _plr.getFoodData().getSaturationLevel() : 0) + 2));
|
||||
}
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.eat")), SoundSource.PLAYERS, (float) 0.5, (float) 0.84);
|
||||
} else {
|
||||
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.generic.eat")), SoundSource.PLAYERS, (float) 0.5, (float) 0.84, false);
|
||||
}
|
||||
}
|
||||
if (world instanceof ServerLevel _level)
|
||||
_level.sendParticles(ParticleTypes.END_ROD, x, y, z, 4, 1, 1, 1, 0.4);
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 600);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMobEffects;
|
||||
|
||||
public class GhoulOnInitialEntitySpawnProcedure {
|
||||
public static void execute(Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
|
||||
_entity.addEffect(new MobEffectInstance(NimsRandomBullshitModMobEffects.SUMMONED_ENTITY_EFFECT.get(), 200, 1, false, false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEntities;
|
||||
|
||||
public class GhoulThisEntityKillsAnotherOneProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z) {
|
||||
if (world instanceof ServerLevel _level) {
|
||||
Entity entityToSpawn = NimsRandomBullshitModEntities.GHOUL.get().spawn(_level, BlockPos.containing(x, y, z), MobSpawnType.MOB_SUMMONED);
|
||||
if (entityToSpawn != null) {
|
||||
entityToSpawn.setDeltaMovement(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEntities;
|
||||
|
||||
public class GravediggerRightclickedOnBlockProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, BlockState blockstate, Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (blockstate == Blocks.SOUL_SAND.defaultBlockState() || blockstate == Blocks.SOUL_SOIL.defaultBlockState()) {
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 16);
|
||||
world.setBlock(BlockPos.containing(x, y, z), Blocks.AIR.defaultBlockState(), 3);
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.blaze.ambient")), SoundSource.HOSTILE, (float) 0.7, (float) Mth.nextDouble(RandomSource.create(), 0.6, 0.7));
|
||||
} else {
|
||||
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.blaze.ambient")), SoundSource.HOSTILE, (float) 0.7, (float) Mth.nextDouble(RandomSource.create(), 0.6, 0.7), false);
|
||||
}
|
||||
}
|
||||
if (world instanceof ServerLevel _level) {
|
||||
Entity entityToSpawn = NimsRandomBullshitModEntities.GHOUL.get().spawn(_level, BlockPos.containing(x, y, z), MobSpawnType.MOB_SUMMONED);
|
||||
if (entityToSpawn != null) {
|
||||
entityToSpawn.setDeltaMovement(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
public class MagicFleshOnPlayerStoppedUsingProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z) {
|
||||
if (world instanceof ServerLevel _level)
|
||||
_level.addFreshEntity(new ExperienceOrb(_level, x, y, z, Mth.nextInt(RandomSource.create(), 6, 9)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEnchantments;
|
||||
|
||||
public class NetherrackingLogicProcedure {
|
||||
public static void execute(LevelAccessor world, Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (itemstack.getEnchantmentLevel(NimsRandomBullshitModEnchantments.NETHERRACKING_ENCHANTMENT.get()) > 0) {
|
||||
if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
|
||||
_entity.addEffect(new MobEffectInstance(MobEffects.DIG_SPEED, 2, (int) (itemstack.getEnchantmentLevel(NimsRandomBullshitModEnchantments.NETHERRACKING_ENCHANTMENT.get()) * 4), false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
public class NetherrackitePickaxeBlockDestroyedWithToolProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, BlockState blockstate) {
|
||||
if (blockstate.getBlock() == Blocks.NETHERRACK) {
|
||||
if (world instanceof ServerLevel _level) {
|
||||
ItemEntity entityToSpawn = new ItemEntity(_level, x, y, z, new ItemStack(Blocks.NETHERRACK));
|
||||
entityToSpawn.setPickUpDelay(10);
|
||||
_level.addFreshEntity(entityToSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Map;
|
||||
|
||||
public class OreMinerGUISlot0ImageDisplayConditionProcedure {
|
||||
public static boolean execute(Entity entity) {
|
||||
if (entity == null)
|
||||
return false;
|
||||
if (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(0) > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Map;
|
||||
|
||||
public class OreMinerMineButtonPressedProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
double oreMinerRoll = 0;
|
||||
if ((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY).getItem() == Items.DIAMOND_PICKAXE) {
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.stone.break")), SoundSource.BLOCKS, (float) 0.8, (float) Mth.nextDouble(RandomSource.create(), 0.9, 1.1));
|
||||
} else {
|
||||
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.stone.break")), SoundSource.BLOCKS, (float) 0.8, (float) Mth.nextDouble(RandomSource.create(), 0.9, 1.1), false);
|
||||
}
|
||||
}
|
||||
{
|
||||
ItemStack _ist = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY);
|
||||
if (_ist.hurt(1, RandomSource.create(), null)) {
|
||||
_ist.shrink(1);
|
||||
_ist.setDamageValue(0);
|
||||
}
|
||||
}
|
||||
oreMinerRoll = Math.random();
|
||||
if (oreMinerRoll < 0.125) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.COAL).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(1) + Mth.nextInt(RandomSource.create(), 1, 3)));
|
||||
((Slot) _slots.get(1)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
} else if (oreMinerRoll < 0.25) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.RAW_COPPER).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(2) + Mth.nextInt(RandomSource.create(), 2, 4)));
|
||||
((Slot) _slots.get(2)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
} else if (oreMinerRoll < 0.375) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.RAW_IRON).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(3) + 1));
|
||||
((Slot) _slots.get(3)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
} else if (oreMinerRoll < 0.5) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.RAW_GOLD).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(4) + 1));
|
||||
((Slot) _slots.get(4)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
} else if (oreMinerRoll < 0.625) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.DIAMOND).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(5) + Mth.nextInt(RandomSource.create(), 1, 2)));
|
||||
((Slot) _slots.get(5)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
} else if (oreMinerRoll < 0.75) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.EMERALD).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(6) + Mth.nextInt(RandomSource.create(), 1, 2)));
|
||||
((Slot) _slots.get(6)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
} else if (oreMinerRoll < 0.875) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.REDSTONE).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(7) + Mth.nextInt(RandomSource.create(), 3, 6)));
|
||||
((Slot) _slots.get(7)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
} else {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = new ItemStack(Items.NETHERITE_SCRAP).copy();
|
||||
_setstack.setCount((int) (new Object() {
|
||||
public int getAmount(int sltid) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
|
||||
if (stack != null)
|
||||
return stack.getCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}.getAmount(8) + 1));
|
||||
((Slot) _slots.get(8)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModEnchantments;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class PassiveIncomeProcedureProcedure {
|
||||
@SubscribeEvent
|
||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
execute(event, event.player.level(), event.player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void execute(LevelAccessor world, Entity entity) {
|
||||
execute(null, world, entity);
|
||||
}
|
||||
|
||||
private static void execute(@Nullable Event event, LevelAccessor world, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
entity.getPersistentData().putDouble("PassiveIncomeCounter", (entity.getPersistentData().getDouble("PassiveIncomeCounter") + 1));
|
||||
if (entity.getPersistentData().getDouble("PassiveIncomeCounter") % 80 == 0) {
|
||||
if ((entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.FEET) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()) > 0) {
|
||||
if (entity instanceof Player _player)
|
||||
_player.giveExperiencePoints(
|
||||
(entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.FEET) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()));
|
||||
}
|
||||
if ((entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.LEGS) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()) > 0) {
|
||||
if (entity instanceof Player _player)
|
||||
_player.giveExperiencePoints(
|
||||
(entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.LEGS) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()));
|
||||
}
|
||||
if ((entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.CHEST) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()) > 0) {
|
||||
if (entity instanceof Player _player)
|
||||
_player.giveExperiencePoints(
|
||||
(entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.CHEST) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()));
|
||||
}
|
||||
if ((entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.HEAD) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()) > 0) {
|
||||
if (entity instanceof Player _player)
|
||||
_player.giveExperiencePoints(
|
||||
(entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.HEAD) : ItemStack.EMPTY).getEnchantmentLevel(NimsRandomBullshitModEnchantments.PASSIVE_INCOME_ENCHANTMENT.get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMobEffects;
|
||||
|
||||
public class ShitProjectileProjectileHitsPlayerProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, Entity sourceentity) {
|
||||
if (entity == null || sourceentity == null)
|
||||
return;
|
||||
if (!(entity == sourceentity)) {
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.ghast.scream")), SoundSource.PLAYERS, (float) 0.8, (float) Mth.nextDouble(RandomSource.create(), 0.9, 1.1));
|
||||
} else {
|
||||
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.ghast.scream")), SoundSource.PLAYERS, (float) 0.8, (float) Mth.nextDouble(RandomSource.create(), 0.9, 1.1), false);
|
||||
}
|
||||
}
|
||||
if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
|
||||
_entity.addEffect(new MobEffectInstance(NimsRandomBullshitModMobEffects.STINKY_EFFECT.get(), 60, 1, false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModItems;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class ShitSpawnLogicProcedure {
|
||||
@SubscribeEvent
|
||||
public static void onEntityTick(LivingEvent.LivingTickEvent event) {
|
||||
execute(event, event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), event.getEntity());
|
||||
}
|
||||
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
execute(null, world, x, y, z, entity);
|
||||
}
|
||||
|
||||
private static void execute(@Nullable Event event, LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
entity.getPersistentData().putDouble("ShitCounter", (entity.getPersistentData().getDouble("ShitCounter") + 1));
|
||||
if (entity.getPersistentData().getDouble("ShitCounter") % 6000 == 0 && Math.random() < 0.125) {
|
||||
if (world instanceof ServerLevel _level) {
|
||||
ItemEntity entityToSpawn = new ItemEntity(_level, x, y, z, new ItemStack(NimsRandomBullshitModItems.SHIT.get()));
|
||||
entityToSpawn.setPickUpDelay(20);
|
||||
_level.addFreshEntity(entityToSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
|
||||
|
||||
public class StinkyEffectEffectExpiresProcedure {
|
||||
public static void execute(Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity instanceof Player _plr0 && _plr0.containerMenu instanceof ShitGUIMenu) {
|
||||
if (entity instanceof Player _player)
|
||||
_player.closeContainer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class StinkyEffectOnEffectActiveTickProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (!(entity instanceof Player _plr0 && _plr0.containerMenu instanceof ShitGUIMenu)) {
|
||||
if (entity instanceof ServerPlayer _ent) {
|
||||
BlockPos _bpos = BlockPos.containing(x, y, z);
|
||||
NetworkHooks.openScreen((ServerPlayer) _ent, new MenuProvider() {
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.literal("ShitGUI");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
|
||||
return new ShitGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(_bpos));
|
||||
}
|
||||
}, _bpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
|
||||
public class SummonedEntityEffectEffectExpiresProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (world instanceof ServerLevel _level)
|
||||
_level.sendParticles(ParticleTypes.SOUL_FIRE_FLAME, x, y, z, 6, 0.6, 0.6, 0.6, 0.16);
|
||||
entity.hurt(new DamageSource(world.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.FELL_OUT_OF_WORLD)), 999);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.world.inventory;
|
||||
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class OreMinerGUIMenu extends AbstractContainerMenu implements Supplier<Map<Integer, Slot>> {
|
||||
public final static HashMap<String, Object> guistate = new HashMap<>();
|
||||
public final Level world;
|
||||
public final Player entity;
|
||||
public int x, y, z;
|
||||
private ContainerLevelAccess access = ContainerLevelAccess.NULL;
|
||||
private IItemHandler internal;
|
||||
private final Map<Integer, Slot> customSlots = new HashMap<>();
|
||||
private boolean bound = false;
|
||||
private Supplier<Boolean> boundItemMatcher = null;
|
||||
private Entity boundEntity = null;
|
||||
private BlockEntity boundBlockEntity = null;
|
||||
|
||||
public OreMinerGUIMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
|
||||
super(NimsRandomBullshitModMenus.ORE_MINER_GUI.get(), id);
|
||||
this.entity = inv.player;
|
||||
this.world = inv.player.level();
|
||||
this.internal = new ItemStackHandler(9);
|
||||
BlockPos pos = null;
|
||||
if (extraData != null) {
|
||||
pos = extraData.readBlockPos();
|
||||
this.x = pos.getX();
|
||||
this.y = pos.getY();
|
||||
this.z = pos.getZ();
|
||||
access = ContainerLevelAccess.create(world, pos);
|
||||
}
|
||||
if (pos != null) {
|
||||
if (extraData.readableBytes() == 1) { // bound to item
|
||||
byte hand = extraData.readByte();
|
||||
ItemStack itemstack = hand == 0 ? this.entity.getMainHandItem() : this.entity.getOffhandItem();
|
||||
this.boundItemMatcher = () -> itemstack == (hand == 0 ? this.entity.getMainHandItem() : this.entity.getOffhandItem());
|
||||
itemstack.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
|
||||
this.internal = capability;
|
||||
this.bound = true;
|
||||
});
|
||||
} else if (extraData.readableBytes() > 1) { // bound to entity
|
||||
extraData.readByte(); // drop padding
|
||||
boundEntity = world.getEntity(extraData.readVarInt());
|
||||
if (boundEntity != null)
|
||||
boundEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
|
||||
this.internal = capability;
|
||||
this.bound = true;
|
||||
});
|
||||
} else { // might be bound to block
|
||||
boundBlockEntity = this.world.getBlockEntity(pos);
|
||||
if (boundBlockEntity != null)
|
||||
boundBlockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
|
||||
this.internal = capability;
|
||||
this.bound = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 31, 17) {
|
||||
private final int slot = 0;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return Items.DIAMOND_PICKAXE == stack.getItem();
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(1, this.addSlot(new SlotItemHandler(internal, 1, 79, 17) {
|
||||
private final int slot = 1;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(2, this.addSlot(new SlotItemHandler(internal, 2, 97, 17) {
|
||||
private final int slot = 2;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(3, this.addSlot(new SlotItemHandler(internal, 3, 115, 17) {
|
||||
private final int slot = 3;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(4, this.addSlot(new SlotItemHandler(internal, 4, 133, 17) {
|
||||
private final int slot = 4;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(5, this.addSlot(new SlotItemHandler(internal, 5, 79, 35) {
|
||||
private final int slot = 5;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(6, this.addSlot(new SlotItemHandler(internal, 6, 97, 35) {
|
||||
private final int slot = 6;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(7, this.addSlot(new SlotItemHandler(internal, 7, 115, 35) {
|
||||
private final int slot = 7;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(8, this.addSlot(new SlotItemHandler(internal, 8, 133, 35) {
|
||||
private final int slot = 8;
|
||||
private int x = OreMinerGUIMenu.this.x;
|
||||
private int y = OreMinerGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
for (int si = 0; si < 3; ++si)
|
||||
for (int sj = 0; sj < 9; ++sj)
|
||||
this.addSlot(new Slot(inv, sj + (si + 1) * 9, 0 + 8 + sj * 18, 0 + 84 + si * 18));
|
||||
for (int si = 0; si < 9; ++si)
|
||||
this.addSlot(new Slot(inv, si, 0 + 8 + si * 18, 0 + 142));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
if (this.bound) {
|
||||
if (this.boundItemMatcher != null)
|
||||
return this.boundItemMatcher.get();
|
||||
else if (this.boundBlockEntity != null)
|
||||
return AbstractContainerMenu.stillValid(this.access, player, this.boundBlockEntity.getBlockState().getBlock());
|
||||
else if (this.boundEntity != null)
|
||||
return this.boundEntity.isAlive();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = (Slot) this.slots.get(index);
|
||||
if (slot != null && slot.hasItem()) {
|
||||
ItemStack itemstack1 = slot.getItem();
|
||||
itemstack = itemstack1.copy();
|
||||
if (index < 9) {
|
||||
if (!this.moveItemStackTo(itemstack1, 9, this.slots.size(), true))
|
||||
return ItemStack.EMPTY;
|
||||
slot.onQuickCraft(itemstack1, itemstack);
|
||||
} else if (!this.moveItemStackTo(itemstack1, 0, 9, false)) {
|
||||
if (index < 9 + 27) {
|
||||
if (!this.moveItemStackTo(itemstack1, 9 + 27, this.slots.size(), true))
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
if (!this.moveItemStackTo(itemstack1, 9, 9 + 27, false))
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (itemstack1.getCount() == 0)
|
||||
slot.set(ItemStack.EMPTY);
|
||||
else
|
||||
slot.setChanged();
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
return ItemStack.EMPTY;
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean moveItemStackTo(ItemStack p_38904_, int p_38905_, int p_38906_, boolean p_38907_) {
|
||||
boolean flag = false;
|
||||
int i = p_38905_;
|
||||
if (p_38907_) {
|
||||
i = p_38906_ - 1;
|
||||
}
|
||||
if (p_38904_.isStackable()) {
|
||||
while (!p_38904_.isEmpty()) {
|
||||
if (p_38907_) {
|
||||
if (i < p_38905_) {
|
||||
break;
|
||||
}
|
||||
} else if (i >= p_38906_) {
|
||||
break;
|
||||
}
|
||||
Slot slot = this.slots.get(i);
|
||||
ItemStack itemstack = slot.getItem();
|
||||
if (slot.mayPlace(itemstack) && !itemstack.isEmpty() && ItemStack.isSameItemSameTags(p_38904_, itemstack)) {
|
||||
int j = itemstack.getCount() + p_38904_.getCount();
|
||||
int maxSize = Math.min(slot.getMaxStackSize(), p_38904_.getMaxStackSize());
|
||||
if (j <= maxSize) {
|
||||
p_38904_.setCount(0);
|
||||
itemstack.setCount(j);
|
||||
slot.set(itemstack);
|
||||
flag = true;
|
||||
} else if (itemstack.getCount() < maxSize) {
|
||||
p_38904_.shrink(maxSize - itemstack.getCount());
|
||||
itemstack.setCount(maxSize);
|
||||
slot.set(itemstack);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (p_38907_) {
|
||||
--i;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!p_38904_.isEmpty()) {
|
||||
if (p_38907_) {
|
||||
i = p_38906_ - 1;
|
||||
} else {
|
||||
i = p_38905_;
|
||||
}
|
||||
while (true) {
|
||||
if (p_38907_) {
|
||||
if (i < p_38905_) {
|
||||
break;
|
||||
}
|
||||
} else if (i >= p_38906_) {
|
||||
break;
|
||||
}
|
||||
Slot slot1 = this.slots.get(i);
|
||||
ItemStack itemstack1 = slot1.getItem();
|
||||
if (itemstack1.isEmpty() && slot1.mayPlace(p_38904_)) {
|
||||
if (p_38904_.getCount() > slot1.getMaxStackSize()) {
|
||||
slot1.setByPlayer(p_38904_.split(slot1.getMaxStackSize()));
|
||||
} else {
|
||||
slot1.setByPlayer(p_38904_.split(p_38904_.getCount()));
|
||||
}
|
||||
slot1.setChanged();
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
if (p_38907_) {
|
||||
--i;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(Player playerIn) {
|
||||
super.removed(playerIn);
|
||||
if (!bound && playerIn instanceof ServerPlayer serverPlayer) {
|
||||
if (!serverPlayer.isAlive() || serverPlayer.hasDisconnected()) {
|
||||
for (int j = 0; j < internal.getSlots(); ++j) {
|
||||
if (j == 0)
|
||||
continue;
|
||||
if (j == 1)
|
||||
continue;
|
||||
if (j == 2)
|
||||
continue;
|
||||
if (j == 3)
|
||||
continue;
|
||||
if (j == 4)
|
||||
continue;
|
||||
if (j == 5)
|
||||
continue;
|
||||
playerIn.drop(internal.extractItem(j, internal.getStackInSlot(j).getCount(), false), false);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < internal.getSlots(); ++i) {
|
||||
if (i == 0)
|
||||
continue;
|
||||
if (i == 1)
|
||||
continue;
|
||||
if (i == 2)
|
||||
continue;
|
||||
if (i == 3)
|
||||
continue;
|
||||
if (i == 4)
|
||||
continue;
|
||||
if (i == 5)
|
||||
continue;
|
||||
playerIn.getInventory().placeItemBackInInventory(internal.extractItem(i, internal.getStackInSlot(i).getCount(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Slot> get() {
|
||||
return customSlots;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.world.inventory;
|
||||
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ShitGUIMenu extends AbstractContainerMenu implements Supplier<Map<Integer, Slot>> {
|
||||
public final static HashMap<String, Object> guistate = new HashMap<>();
|
||||
public final Level world;
|
||||
public final Player entity;
|
||||
public int x, y, z;
|
||||
private ContainerLevelAccess access = ContainerLevelAccess.NULL;
|
||||
private IItemHandler internal;
|
||||
private final Map<Integer, Slot> customSlots = new HashMap<>();
|
||||
private boolean bound = false;
|
||||
private Supplier<Boolean> boundItemMatcher = null;
|
||||
private Entity boundEntity = null;
|
||||
private BlockEntity boundBlockEntity = null;
|
||||
|
||||
public ShitGUIMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
|
||||
super(NimsRandomBullshitModMenus.SHIT_GUI.get(), id);
|
||||
this.entity = inv.player;
|
||||
this.world = inv.player.level();
|
||||
this.internal = new ItemStackHandler(0);
|
||||
BlockPos pos = null;
|
||||
if (extraData != null) {
|
||||
pos = extraData.readBlockPos();
|
||||
this.x = pos.getX();
|
||||
this.y = pos.getY();
|
||||
this.z = pos.getZ();
|
||||
access = ContainerLevelAccess.create(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
if (this.bound) {
|
||||
if (this.boundItemMatcher != null)
|
||||
return this.boundItemMatcher.get();
|
||||
else if (this.boundBlockEntity != null)
|
||||
return AbstractContainerMenu.stillValid(this.access, player, this.boundBlockEntity.getBlockState().getBlock());
|
||||
else if (this.boundEntity != null)
|
||||
return this.boundEntity.isAlive();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public Map<Integer, Slot> get() {
|
||||
return customSlots;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user