mirror of
https://github.com/nimsolated/Nims-Random-BS.git
synced 2026-04-02 10:20:42 -07:00
update: 1.6.0
This commit is contained in:
@@ -17,7 +17,9 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModVillagerProfessions;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModTabs;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModPaintings;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMobEffects;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModItems;
|
||||
@@ -57,6 +59,9 @@ public class NimsRandomBullshitMod {
|
||||
|
||||
NimsRandomBullshitModMobEffects.REGISTRY.register(bus);
|
||||
|
||||
NimsRandomBullshitModPaintings.REGISTRY.register(bus);
|
||||
|
||||
NimsRandomBullshitModVillagerProfessions.PROFESSIONS.register(bus);
|
||||
NimsRandomBullshitModMenus.REGISTRY.register(bus);
|
||||
NimsRandomBullshitModFluids.REGISTRY.register(bus);
|
||||
NimsRandomBullshitModFluidTypes.REGISTRY.register(bus);
|
||||
|
||||
@@ -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.BedrockifierGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.block.entity.BedrockifierBlockEntity;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class BedrockifierBlock extends Block implements EntityBlock {
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
|
||||
public BedrockifierBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(-1, 3600000).requiresCorrectToolForDrops());
|
||||
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("Bedrockifier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
|
||||
return new BedrockifierGUIMenu(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 BedrockifierBlockEntity(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 BedrockifierBlockEntity 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 BedrockifierBlockEntity be)
|
||||
return AbstractContainerMenu.getRedstoneSignalFromContainer(be);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
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.BedrockifierGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlockEntities;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class BedrockifierBlockEntity extends RandomizableContainerBlockEntity implements WorldlyContainer {
|
||||
private NonNullList<ItemStack> stacks = NonNullList.<ItemStack>withSize(3, ItemStack.EMPTY);
|
||||
private final LazyOptional<? extends IItemHandler>[] handlers = SidedInvWrapper.create(this, Direction.values());
|
||||
|
||||
public BedrockifierBlockEntity(BlockPos position, BlockState state) {
|
||||
super(NimsRandomBullshitModBlockEntities.BEDROCKIFIER.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("bedrockifier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inventory) {
|
||||
return new BedrockifierGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(this.worldPosition));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.literal("Bedrockifier");
|
||||
}
|
||||
|
||||
@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 == 2)
|
||||
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.BedrockifierGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.network.BedrockifierGUIButtonMessage;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
public class BedrockifierGUIScreen extends AbstractContainerScreen<BedrockifierGUIMenu> {
|
||||
private final static HashMap<String, Object> guistate = BedrockifierGUIMenu.guistate;
|
||||
private final Level world;
|
||||
private final int x, y, z;
|
||||
private final Player entity;
|
||||
Button button_empty;
|
||||
|
||||
public BedrockifierGUIScreen(BedrockifierGUIMenu 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/bedrockifier_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);
|
||||
|
||||
guiGraphics.blit(new ResourceLocation("nims_random_bullshit:textures/screens/plus_sign.png"), this.leftPos + 42, this.topPos + 34, 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) {
|
||||
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.bedrockifier_gui.label_bedrockifier"), 6, 7, -12829636, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
button_empty = Button.builder(Component.translatable("gui.nims_random_bullshit.bedrockifier_gui.button_empty"), e -> {
|
||||
if (true) {
|
||||
NimsRandomBullshitMod.PACKET_HANDLER.sendToServer(new BedrockifierGUIButtonMessage(0, x, y, z));
|
||||
BedrockifierGUIButtonMessage.handleButtonAction(entity, 0, x, y, z);
|
||||
}
|
||||
}).bounds(this.leftPos + 96, this.topPos + 34, 35, 20).build();
|
||||
guistate.put("button:button_empty", button_empty);
|
||||
this.addRenderableWidget(button_empty);
|
||||
}
|
||||
}
|
||||
@@ -169,9 +169,9 @@ public class GhoulEntity extends Monster {
|
||||
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.MAX_HEALTH, 10);
|
||||
builder = builder.add(Attributes.ARMOR, 0);
|
||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 3);
|
||||
builder = builder.add(Attributes.ATTACK_DAMAGE, 6);
|
||||
builder = builder.add(Attributes.FOLLOW_RANGE, 19);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.mcreator.nimsrandombullshit.block.entity.OreMinerBlockEntity;
|
||||
import net.mcreator.nimsrandombullshit.block.entity.MailboxBlockEntity;
|
||||
import net.mcreator.nimsrandombullshit.block.entity.LabelCopyMachineBlockEntity;
|
||||
import net.mcreator.nimsrandombullshit.block.entity.BedrockifierBlockEntity;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModBlockEntities {
|
||||
@@ -21,6 +22,7 @@ public class NimsRandomBullshitModBlockEntities {
|
||||
public static final RegistryObject<BlockEntityType<?>> ORE_MINER = register("ore_miner", NimsRandomBullshitModBlocks.ORE_MINER, OreMinerBlockEntity::new);
|
||||
public static final RegistryObject<BlockEntityType<?>> MAILBOX = register("mailbox", NimsRandomBullshitModBlocks.MAILBOX, MailboxBlockEntity::new);
|
||||
public static final RegistryObject<BlockEntityType<?>> LABEL_COPY_MACHINE = register("label_copy_machine", NimsRandomBullshitModBlocks.LABEL_COPY_MACHINE, LabelCopyMachineBlockEntity::new);
|
||||
public static final RegistryObject<BlockEntityType<?>> BEDROCKIFIER = register("bedrockifier", NimsRandomBullshitModBlocks.BEDROCKIFIER, BedrockifierBlockEntity::new);
|
||||
|
||||
// Start of user code block custom block entities
|
||||
// End of user code block custom block entities
|
||||
|
||||
@@ -31,6 +31,7 @@ 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.block.BedrockifierBlock;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModBlocks {
|
||||
@@ -56,6 +57,7 @@ public class NimsRandomBullshitModBlocks {
|
||||
public static final RegistryObject<Block> MAGMA_BRICK_WALLS = REGISTRY.register("magma_brick_walls", () -> new MagmaBrickWallsBlock());
|
||||
public static final RegistryObject<Block> MAGMA_BRICK_PRESSURE_PLATE = REGISTRY.register("magma_brick_pressure_plate", () -> new MagmaBrickPressurePlateBlock());
|
||||
public static final RegistryObject<Block> MAGMA_BRICK_BUTTON = REGISTRY.register("magma_brick_button", () -> new MagmaBrickButtonBlock());
|
||||
public static final RegistryObject<Block> BEDROCKIFIER = REGISTRY.register("bedrockifier", () -> new BedrockifierBlock());
|
||||
// Start of user code block custom blocks
|
||||
// End of user code block custom blocks
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.item.WitherQuestionMarkItem;
|
||||
import net.mcreator.nimsrandombullshit.item.StarWandItem;
|
||||
import net.mcreator.nimsrandombullshit.item.StarItem;
|
||||
import net.mcreator.nimsrandombullshit.item.SnowGolemQuestionMarkItem;
|
||||
import net.mcreator.nimsrandombullshit.item.ShitItem;
|
||||
import net.mcreator.nimsrandombullshit.item.ShippingLabelItem;
|
||||
import net.mcreator.nimsrandombullshit.item.SandDustItem;
|
||||
@@ -22,12 +24,17 @@ import net.mcreator.nimsrandombullshit.item.NetherrackitePickaxeItem;
|
||||
import net.mcreator.nimsrandombullshit.item.NetherrackiteItem;
|
||||
import net.mcreator.nimsrandombullshit.item.NetherrackJuiceItem;
|
||||
import net.mcreator.nimsrandombullshit.item.MagicFleshItem;
|
||||
import net.mcreator.nimsrandombullshit.item.MagicEggItem;
|
||||
import net.mcreator.nimsrandombullshit.item.MagicDustItem;
|
||||
import net.mcreator.nimsrandombullshit.item.LapisLazuliNuggetItem;
|
||||
import net.mcreator.nimsrandombullshit.item.IronGolemQuestionMarkItem;
|
||||
import net.mcreator.nimsrandombullshit.item.GravediggerItem;
|
||||
import net.mcreator.nimsrandombullshit.item.GoldenBerriesItem;
|
||||
import net.mcreator.nimsrandombullshit.item.CheeseItem;
|
||||
import net.mcreator.nimsrandombullshit.item.BlockEaterItem;
|
||||
import net.mcreator.nimsrandombullshit.item.BedrockUpgradeTemplateItem;
|
||||
import net.mcreator.nimsrandombullshit.item.BedrockSwordItem;
|
||||
import net.mcreator.nimsrandombullshit.item.BedrockPickaxeItem;
|
||||
import net.mcreator.nimsrandombullshit.item.BeanItem;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
@@ -71,6 +78,14 @@ public class NimsRandomBullshitModItems {
|
||||
public static final RegistryObject<Item> MAGMA_BRICK_BUTTON = block(NimsRandomBullshitModBlocks.MAGMA_BRICK_BUTTON);
|
||||
public static final RegistryObject<Item> BEAN = REGISTRY.register("bean", () -> new BeanItem());
|
||||
public static final RegistryObject<Item> CHEESE = REGISTRY.register("cheese", () -> new CheeseItem());
|
||||
public static final RegistryObject<Item> BEDROCK_PICKAXE = REGISTRY.register("bedrock_pickaxe", () -> new BedrockPickaxeItem());
|
||||
public static final RegistryObject<Item> BEDROCK_UPGRADE_TEMPLATE = REGISTRY.register("bedrock_upgrade_template", () -> new BedrockUpgradeTemplateItem());
|
||||
public static final RegistryObject<Item> BEDROCKIFIER = block(NimsRandomBullshitModBlocks.BEDROCKIFIER);
|
||||
public static final RegistryObject<Item> MAGIC_EGG = REGISTRY.register("magic_egg", () -> new MagicEggItem());
|
||||
public static final RegistryObject<Item> WITHER_QUESTION_MARK = REGISTRY.register("wither_question_mark", () -> new WitherQuestionMarkItem());
|
||||
public static final RegistryObject<Item> IRON_GOLEM_QUESTION_MARK = REGISTRY.register("iron_golem_question_mark", () -> new IronGolemQuestionMarkItem());
|
||||
public static final RegistryObject<Item> SNOW_GOLEM_QUESTION_MARK = REGISTRY.register("snow_golem_question_mark", () -> new SnowGolemQuestionMarkItem());
|
||||
public static final RegistryObject<Item> BEDROCK_SWORD = REGISTRY.register("bedrock_sword", () -> new BedrockSwordItem());
|
||||
|
||||
// Start of user code block custom items
|
||||
// End of user code block custom items
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.LabelCopyMachineGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.BedrockifierGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModMenus {
|
||||
@@ -25,4 +26,5 @@ public class NimsRandomBullshitModMenus {
|
||||
public static final RegistryObject<MenuType<MailboxGUIMenu>> MAILBOX_GUI = REGISTRY.register("mailbox_gui", () -> IForgeMenuType.create(MailboxGUIMenu::new));
|
||||
public static final RegistryObject<MenuType<MailboxNameEntryGUIMenu>> MAILBOX_NAME_ENTRY_GUI = REGISTRY.register("mailbox_name_entry_gui", () -> IForgeMenuType.create(MailboxNameEntryGUIMenu::new));
|
||||
public static final RegistryObject<MenuType<LabelCopyMachineGUIMenu>> LABEL_COPY_MACHINE_GUI = REGISTRY.register("label_copy_machine_gui", () -> IForgeMenuType.create(LabelCopyMachineGUIMenu::new));
|
||||
public static final RegistryObject<MenuType<BedrockifierGUIMenu>> BEDROCKIFIER_GUI = REGISTRY.register("bedrockifier_gui", () -> IForgeMenuType.create(BedrockifierGUIMenu::new));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
/*
|
||||
* 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.entity.decoration.PaintingVariant;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
public class NimsRandomBullshitModPaintings {
|
||||
public static final DeferredRegister<PaintingVariant> REGISTRY = DeferredRegister.create(ForgeRegistries.PAINTING_VARIANTS, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<PaintingVariant> SHIT_PAINTING = REGISTRY.register("shit_painting", () -> new PaintingVariant(16, 16));
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import net.mcreator.nimsrandombullshit.client.gui.OreMinerGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.MailboxNameEntryGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.MailboxGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.LabelCopyMachineGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.BedrockifierGUIScreen;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public class NimsRandomBullshitModScreens {
|
||||
@@ -27,6 +28,7 @@ public class NimsRandomBullshitModScreens {
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_GUI.get(), MailboxGUIScreen::new);
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_NAME_ENTRY_GUI.get(), MailboxNameEntryGUIScreen::new);
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.LABEL_COPY_MACHINE_GUI.get(), LabelCopyMachineGUIScreen::new);
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.BEDROCKIFIER_GUI.get(), BedrockifierGUIScreen::new);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,19 @@ public class NimsRandomBullshitModTabs {
|
||||
tabData.accept(NimsRandomBullshitModItems.STAR_WAND.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.NETHERRACK_JUICE_BUCKET.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.SHIPPING_LABEL.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.BEDROCK_PICKAXE.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.BEDROCK_SWORD.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());
|
||||
tabData.accept(NimsRandomBullshitModItems.STAR.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.BEDROCK_UPGRADE_TEMPLATE.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.MAGIC_EGG.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.WITHER_QUESTION_MARK.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.IRON_GOLEM_QUESTION_MARK.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.SNOW_GOLEM_QUESTION_MARK.get());
|
||||
} else if (tabData.getTabKey() == CreativeModeTabs.FOOD_AND_DRINKS) {
|
||||
tabData.accept(NimsRandomBullshitModItems.MAGIC_FLESH.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.GOLDEN_BERRIES.get());
|
||||
@@ -56,6 +63,7 @@ public class NimsRandomBullshitModTabs {
|
||||
tabData.accept(NimsRandomBullshitModBlocks.ORE_MINER.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.MAILBOX.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.LABEL_COPY_MACHINE.get().asItem());
|
||||
tabData.accept(NimsRandomBullshitModBlocks.BEDROCKIFIER.get().asItem());
|
||||
} else if (tabData.getTabKey() == CreativeModeTabs.SPAWN_EGGS) {
|
||||
tabData.accept(NimsRandomBullshitModItems.GHOUL_SPAWN_EGG.get());
|
||||
tabData.accept(NimsRandomBullshitModItems.TUX_SPAWN_EGG.get());
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
/*
|
||||
* 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.event.village.VillagerTradesEvent;
|
||||
import net.minecraftforge.common.BasicItemListing;
|
||||
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class NimsRandomBullshitModTrades {
|
||||
@SubscribeEvent
|
||||
public static void registerTrades(VillagerTradesEvent event) {
|
||||
if (event.getType() == NimsRandomBullshitModVillagerProfessions.MAILMAN_PROFESSION.get()) {
|
||||
event.getTrades().get(1).add(new BasicItemListing(new ItemStack(Items.EMERALD),
|
||||
|
||||
new ItemStack(NimsRandomBullshitModItems.SHIPPING_LABEL.get(), 12), 100, 5, 0.05f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.nimsrandombullshit.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiType;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.Holder;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.Optional;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class NimsRandomBullshitModVillagerProfessions {
|
||||
private static final Map<String, ProfessionPoiType> POI_TYPES = new HashMap<>();
|
||||
public static final DeferredRegister<VillagerProfession> PROFESSIONS = DeferredRegister.create(ForgeRegistries.VILLAGER_PROFESSIONS, NimsRandomBullshitMod.MODID);
|
||||
public static final RegistryObject<VillagerProfession> MAILMAN_PROFESSION = registerProfession("mailman_profession", () -> NimsRandomBullshitModBlocks.MAILBOX.get(),
|
||||
() -> ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("item.book.page_turn")));
|
||||
|
||||
private static RegistryObject<VillagerProfession> registerProfession(String name, Supplier<Block> block, Supplier<SoundEvent> soundEvent) {
|
||||
POI_TYPES.put(name, new ProfessionPoiType(block, null));
|
||||
return PROFESSIONS.register(name, () -> {
|
||||
Predicate<Holder<PoiType>> poiPredicate = poiTypeHolder -> (POI_TYPES.get(name).poiType != null) && (poiTypeHolder.get() == POI_TYPES.get(name).poiType.get());
|
||||
return new VillagerProfession(NimsRandomBullshitMod.MODID + ":" + name, poiPredicate, poiPredicate, ImmutableSet.of(), ImmutableSet.of(), soundEvent.get());
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerProfessionPointsOfInterest(RegisterEvent event) {
|
||||
event.register(ForgeRegistries.Keys.POI_TYPES, registerHelper -> {
|
||||
for (Map.Entry<String, ProfessionPoiType> entry : POI_TYPES.entrySet()) {
|
||||
Block block = entry.getValue().block.get();
|
||||
String name = entry.getKey();
|
||||
Optional<Holder<PoiType>> existingCheck = PoiTypes.forState(block.defaultBlockState());
|
||||
if (existingCheck.isPresent()) {
|
||||
NimsRandomBullshitMod.LOGGER.error("Skipping villager profession " + name + " that uses POI block " + block + " that is already in use by " + existingCheck);
|
||||
continue;
|
||||
}
|
||||
PoiType poiType = new PoiType(ImmutableSet.copyOf(block.getStateDefinition().getPossibleStates()), 1, 1);
|
||||
registerHelper.register(name, poiType);
|
||||
entry.getValue().poiType = ForgeRegistries.POI_TYPES.getHolder(poiType).get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class ProfessionPoiType {
|
||||
final Supplier<Block> block;
|
||||
Holder<PoiType> poiType;
|
||||
|
||||
ProfessionPoiType(Supplier<Block> block, Holder<PoiType> poiType) {
|
||||
this.block = block;
|
||||
this.poiType = poiType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
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.mcreator.nimsrandombullshit.procedures.BedrockPickaxeEntitySwingsItemProcedure;
|
||||
|
||||
public class BedrockPickaxeItem extends PickaxeItem {
|
||||
public BedrockPickaxeItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return 9f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return 6f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 19;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(Blocks.BEDROCK));
|
||||
}
|
||||
}, 1, -2.8f, new Item.Properties().fireResistant());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEntitySwing(ItemStack itemstack, LivingEntity entity) {
|
||||
boolean retval = super.onEntitySwing(itemstack, entity);
|
||||
BedrockPickaxeEntitySwingsItemProcedure.execute(entity.level(), entity);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class BedrockSwordItem extends SwordItem {
|
||||
public BedrockSwordItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return 4f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return 76f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 19;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of();
|
||||
}
|
||||
}, 3, -2.4f, new Item.Properties().fireResistant());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class BedrockUpgradeTemplateItem extends Item {
|
||||
public BedrockUpgradeTemplateItem() {
|
||||
super(new Item.Properties().stacksTo(64).fireResistant().rarity(Rarity.EPIC));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class IronGolemQuestionMarkItem extends Item {
|
||||
public IronGolemQuestionMarkItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class MagicEggItem extends Item {
|
||||
public MagicEggItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class SnowGolemQuestionMarkItem extends Item {
|
||||
public SnowGolemQuestionMarkItem() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.UNCOMMON));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.item;
|
||||
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class WitherQuestionMarkItem extends Item {
|
||||
public WitherQuestionMarkItem() {
|
||||
super(new Item.Properties().stacksTo(64).fireResistant().rarity(Rarity.RARE));
|
||||
}
|
||||
}
|
||||
@@ -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.BedrockifierGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.procedures.BedrockifierButtonPressLogicProcedure;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class BedrockifierGUIButtonMessage {
|
||||
private final int buttonID, x, y, z;
|
||||
|
||||
public BedrockifierGUIButtonMessage(FriendlyByteBuf buffer) {
|
||||
this.buttonID = buffer.readInt();
|
||||
this.x = buffer.readInt();
|
||||
this.y = buffer.readInt();
|
||||
this.z = buffer.readInt();
|
||||
}
|
||||
|
||||
public BedrockifierGUIButtonMessage(int buttonID, int x, int y, int z) {
|
||||
this.buttonID = buttonID;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static void buffer(BedrockifierGUIButtonMessage message, FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(message.buttonID);
|
||||
buffer.writeInt(message.x);
|
||||
buffer.writeInt(message.y);
|
||||
buffer.writeInt(message.z);
|
||||
}
|
||||
|
||||
public static void handler(BedrockifierGUIButtonMessage 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 = BedrockifierGUIMenu.guistate;
|
||||
// security measure to prevent arbitrary chunk generation
|
||||
if (!world.hasChunkAt(new BlockPos(x, y, z)))
|
||||
return;
|
||||
if (buttonID == 0) {
|
||||
|
||||
BedrockifierButtonPressLogicProcedure.execute(world, x, y, z, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerMessage(FMLCommonSetupEvent event) {
|
||||
NimsRandomBullshitMod.addNetworkMessage(BedrockifierGUIButtonMessage.class, BedrockifierGUIButtonMessage::buffer, BedrockifierGUIButtonMessage::new, BedrockifierGUIButtonMessage::handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
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.level.ClipContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
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.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlocks;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BedrockPickaxeEntitySwingsItemProcedure {
|
||||
public static void execute(LevelAccessor world, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (!world.isClientSide()) {
|
||||
if ((world.getBlockState(
|
||||
new BlockPos(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ())))
|
||||
.getBlock() == Blocks.BEDROCK) {
|
||||
{
|
||||
BlockPos _bp = new BlockPos(
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ());
|
||||
BlockState _bs = Blocks.AIR.defaultBlockState();
|
||||
BlockState _bso = world.getBlockState(_bp);
|
||||
for (Map.Entry<Property<?>, Comparable<?>> entry : _bso.getValues().entrySet()) {
|
||||
Property _property = _bs.getBlock().getStateDefinition().getProperty(entry.getKey().getName());
|
||||
if (_property != null && _bs.getValue(_property) != null)
|
||||
try {
|
||||
_bs = _bs.setValue(_property, (Comparable) entry.getValue());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
world.setBlock(_bp, _bs, 3);
|
||||
}
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, new BlockPos(
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
|
||||
ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.stone.break")), SoundSource.BLOCKS, (float) 0.8, (float) 0.8);
|
||||
} else {
|
||||
_level.playLocalSound(
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
|
||||
ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.stone.break")), SoundSource.BLOCKS, (float) 0.8, (float) 0.8, false);
|
||||
}
|
||||
}
|
||||
if (world instanceof ServerLevel _level) {
|
||||
ItemEntity entityToSpawn = new ItemEntity(_level,
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
|
||||
new ItemStack(Blocks.BEDROCK));
|
||||
entityToSpawn.setPickUpDelay(10);
|
||||
_level.addFreshEntity(entityToSpawn);
|
||||
}
|
||||
} else if ((world.getBlockState(
|
||||
new BlockPos(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ())))
|
||||
.getBlock() == NimsRandomBullshitModBlocks.BEDROCKIFIER.get()) {
|
||||
{
|
||||
BlockPos _bp = new BlockPos(
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ());
|
||||
BlockState _bs = Blocks.AIR.defaultBlockState();
|
||||
BlockState _bso = world.getBlockState(_bp);
|
||||
for (Map.Entry<Property<?>, Comparable<?>> entry : _bso.getValues().entrySet()) {
|
||||
Property _property = _bs.getBlock().getStateDefinition().getProperty(entry.getKey().getName());
|
||||
if (_property != null && _bs.getValue(_property) != null)
|
||||
try {
|
||||
_bs = _bs.setValue(_property, (Comparable) entry.getValue());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
world.setBlock(_bp, _bs, 3);
|
||||
}
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, new BlockPos(
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY(),
|
||||
entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
|
||||
ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.stone.break")), SoundSource.BLOCKS, (float) 0.8, (float) 0.8);
|
||||
} else {
|
||||
_level.playLocalSound(
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
|
||||
ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.stone.break")), SoundSource.BLOCKS, (float) 0.8, (float) 0.8, false);
|
||||
}
|
||||
}
|
||||
if (world instanceof ServerLevel _level) {
|
||||
ItemEntity entityToSpawn = new ItemEntity(_level,
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY()),
|
||||
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
|
||||
new ItemStack(NimsRandomBullshitModBlocks.BEDROCKIFIER.get()));
|
||||
entityToSpawn.setPickUpDelay(10);
|
||||
_level.addFreshEntity(entityToSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
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.inventory.Slot;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
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 BedrockifierButtonPressLogicProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (!world.isClientSide()) {
|
||||
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) {
|
||||
if ((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY).getOrCreateTag()
|
||||
.getBoolean("Unbreakable") == false
|
||||
&& (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(1)).getItem() : ItemStack.EMPTY).getItem() == Blocks.BEDROCK.asItem()) {
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY).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) + 1));
|
||||
((Slot) _slots.get(2)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(0)).getItem() : ItemStack.EMPTY).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(0) - 1));
|
||||
((Slot) _slots.get(0)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
|
||||
ItemStack _setstack = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(1)).getItem() : ItemStack.EMPTY).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) - 1));
|
||||
((Slot) _slots.get(1)).set(_setstack);
|
||||
_player.containerMenu.broadcastChanges();
|
||||
}
|
||||
(entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(2)).getItem() : ItemStack.EMPTY).getOrCreateTag().putBoolean("Unbreakable",
|
||||
true);
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.smithing_table.use")), SoundSource.BLOCKS, (float) 0.8, (float) 0.8);
|
||||
} else {
|
||||
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.smithing_table.use")), SoundSource.BLOCKS, (float) 0.8, (float) 0.8, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,27 +32,29 @@ public class PassiveIncomeProcedureProcedure {
|
||||
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") % 3340 == 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()));
|
||||
if (!world.isClientSide()) {
|
||||
entity.getPersistentData().putDouble("PassiveIncomeCounter", (entity.getPersistentData().getDouble("PassiveIncomeCounter") + 1));
|
||||
if (entity.getPersistentData().getDouble("PassiveIncomeCounter") % 1340 == 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ShitProjectileProjectileHitsPlayerProcedure {
|
||||
}
|
||||
}
|
||||
if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
|
||||
_entity.addEffect(new MobEffectInstance(NimsRandomBullshitModMobEffects.STINKY_EFFECT.get(), 60, 1, false, false));
|
||||
_entity.addEffect(new MobEffectInstance(NimsRandomBullshitModMobEffects.STINKY_EFFECT.get(), 20, 1, false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
|
||||
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.block.Blocks;
|
||||
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.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 BedrockifierGUIMenu 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 BedrockifierGUIMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
|
||||
super(NimsRandomBullshitModMenus.BEDROCKIFIER_GUI.get(), id);
|
||||
this.entity = inv.player;
|
||||
this.world = inv.player.level();
|
||||
this.internal = new ItemStackHandler(3);
|
||||
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, 16, 35) {
|
||||
private final int slot = 0;
|
||||
private int x = BedrockifierGUIMenu.this.x;
|
||||
private int y = BedrockifierGUIMenu.this.y;
|
||||
}));
|
||||
this.customSlots.put(1, this.addSlot(new SlotItemHandler(internal, 1, 70, 35) {
|
||||
private final int slot = 1;
|
||||
private int x = BedrockifierGUIMenu.this.x;
|
||||
private int y = BedrockifierGUIMenu.this.y;
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(ItemStack stack) {
|
||||
return Blocks.BEDROCK.asItem() == stack.getItem();
|
||||
}
|
||||
}));
|
||||
this.customSlots.put(2, this.addSlot(new SlotItemHandler(internal, 2, 142, 35) {
|
||||
private final int slot = 2;
|
||||
private int x = BedrockifierGUIMenu.this.x;
|
||||
private int y = BedrockifierGUIMenu.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 < 3) {
|
||||
if (!this.moveItemStackTo(itemstack1, 3, this.slots.size(), true))
|
||||
return ItemStack.EMPTY;
|
||||
slot.onQuickCraft(itemstack1, itemstack);
|
||||
} else if (!this.moveItemStackTo(itemstack1, 0, 3, false)) {
|
||||
if (index < 3 + 27) {
|
||||
if (!this.moveItemStackTo(itemstack1, 3 + 27, this.slots.size(), true))
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
if (!this.moveItemStackTo(itemstack1, 3, 3 + 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;
|
||||
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;
|
||||
playerIn.getInventory().placeItemBackInInventory(internal.extractItem(i, internal.getStackInSlot(i).getCount(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Slot> get() {
|
||||
return customSlots;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user