Initial commit

This commit is contained in:
oitsjustjose 2022-10-15 23:50:15 -05:00
commit 16cb2ea2de
34 changed files with 2889 additions and 0 deletions

View file

@ -0,0 +1,44 @@
package com.oitsjustjose.charged_explosives;
import com.oitsjustjose.charged_explosives.client.ClientProxy;
import com.oitsjustjose.charged_explosives.common.CommonProxy;
import com.oitsjustjose.charged_explosives.common.registry.Registry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Mod(ChargedExplosives.MODID)
public class ChargedExplosives {
private static ChargedExplosives instance;
public static final String MODID = "charged_explosives";
public final Logger LOGGER = LogManager.getLogger();
public final Registry REGISTRY = new Registry();
public final CommonProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
public ChargedExplosives() {
instance = this;
REGISTRY.BlockRegistry.register(FMLJavaModLoadingContext.get().getModEventBus());
REGISTRY.ItemRegistry.register(FMLJavaModLoadingContext.get().getModEventBus());
MinecraftForge.EVENT_BUS.register(this);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
}
public static ChargedExplosives getInstance() {
return instance;
}
public void setup(final FMLCommonSetupEvent evt) {
proxy.init();
}
@SubscribeEvent
public void onSlashReload(AddReloadListenerEvent evt) {
}
}

View file

@ -0,0 +1,29 @@
package com.oitsjustjose.charged_explosives.client;
import com.oitsjustjose.charged_explosives.client.network.ClientOpenGuiPacket;
import com.oitsjustjose.charged_explosives.common.CommonProxy;
import com.oitsjustjose.charged_explosives.common.network.OpenGuiPacket;
import com.oitsjustjose.charged_explosives.common.network.UpdateNbtPacket;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.network.NetworkDirection;
import java.util.Optional;
public class ClientProxy extends CommonProxy {
@Override
public void init() {
CommonProxy.netMgr.networkWrapper.registerMessage(CommonProxy.disc++, OpenGuiPacket.class, OpenGuiPacket::encode, OpenGuiPacket::decode, ClientOpenGuiPacket::handleClient);
CommonProxy.netMgr.networkWrapper.registerMessage(CommonProxy.disc++, UpdateNbtPacket.class, UpdateNbtPacket::encode, UpdateNbtPacket::decode, UpdateNbtPacket::handleClient, Optional.of(NetworkDirection.PLAY_TO_SERVER));
}
@Override
public void updateItemNbt(ItemStack stack) {
UpdateNbtPacket pkt = new UpdateNbtPacket(stack);
CommonProxy.netMgr.networkWrapper.sendToServer(pkt);
}
public void openExplosiveGui(Player player, ItemStack stack) {
super.openExplosiveGui(player, stack);
}
}

View file

@ -0,0 +1,231 @@
package com.oitsjustjose.charged_explosives.client;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.oitsjustjose.charged_explosives.ChargedExplosives;
import com.oitsjustjose.charged_explosives.common.Util;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.event.ScreenEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.function.Function;
public class ExplosionConfigScreen extends Screen {
/* Instance-related stuff that changes regularly */
private int explosionWidth = 0;
private int explosionHeight = 0;
private int explosionDepth = 0;
private final ItemStack stack;
private boolean dirty = false;
/* Refs to UI objects */
private EditBox widthBox;
private EditBox depthBox;
private EditBox heightBox;
private Component widthTitle = Util.translateOrFallback(ChargedExplosives.MODID + ".explosion.width.title");
private Component depthTitle = Util.translateOrFallback(ChargedExplosives.MODID + ".explosion.depth.title");
private Component heightTitle = Util.translateOrFallback(ChargedExplosives.MODID + ".explosion.height.title");
/* Constants */
private final int TEXTURE_WIDTH = 176;
private final int TEXTURE_HEIGHT = 166;
private final int PADDING = 8;
private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation(ChargedExplosives.MODID, "textures/gui/background.png");
public ExplosionConfigScreen(ItemStack stack) {
super(Util.translateOrFallback(ChargedExplosives.MODID + ".explosion.configuration.title"));
this.stack = stack;
assert !this.stack.isEmpty() && this.stack.getTag() != null;
if (this.stack.getTag().contains("explosionWidth") && this.stack.getTag().contains("explosionDepth") && this.stack.getTag().contains("explosionHeight")) {
CompoundTag tag = this.stack.getTag();
this.explosionWidth = tag.getInt("explosionWidth");
this.explosionDepth = tag.getInt("explosionDepth");
this.explosionHeight = tag.getInt("explosionHeight");
}
}
@Override
protected void init() {
super.init();
final Component INCR = Component.literal("+");
final Component DECR = Component.literal("-");
final int INCR_W = this.font.width(INCR) + PADDING;
final int DECR_W = this.font.width(DECR) + PADDING;
final int BG_X = (this.width - TEXTURE_WIDTH) / 2;
final int BG_Y = (this.height - TEXTURE_HEIGHT) / 2;
final int FW_MOD = 0;
final int EB_MOD = 20;
final int LW_MOD = 65;
final int EDIT_BOX_WIDTH = 40;
int rowWidth =/* Width of actual els */ INCR_W + DECR_W + EDIT_BOX_WIDTH
+ (LW_MOD - EDIT_BOX_WIDTH) /* Offset for the left btn */
+ (LW_MOD - EDIT_BOX_WIDTH - EB_MOD) /* Offset for the right btn */;
/* Width Adj */
this.widthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + (rowWidth / 2) + EB_MOD, BG_Y + 40, EDIT_BOX_WIDTH, 20, Component.literal("")));
this.widthBox.setValue("" + this.explosionWidth);
this.addRenderableWidget(new Button(BG_X + (rowWidth / 2) + FW_MOD, BG_Y + 40, DECR_W, 20, DECR, onPress -> {
if (this.explosionWidth > 0) {
this.explosionWidth--;
this.dirty = true;
this.widthBox.setValue("" + this.explosionWidth);
}
}));
this.addRenderableWidget(new Button(BG_X + (rowWidth / 2) + LW_MOD, BG_Y + 40, INCR_W, 20, INCR, onPress -> {
this.explosionWidth++;
this.dirty = true;
this.widthBox.setValue("" + this.explosionWidth);
}));
/* Depth Adj */
this.depthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + (rowWidth / 2) + EB_MOD, BG_Y + 85, EDIT_BOX_WIDTH, 20, Component.literal("")));
this.depthBox.setValue("" + this.explosionDepth);
this.addRenderableWidget(new Button(BG_X + (rowWidth / 2) + FW_MOD, BG_Y + 85, DECR_W, 20, DECR, onPress -> {
if (this.explosionDepth > 0) {
this.explosionDepth--;
this.dirty = true;
this.depthBox.setValue("" + this.explosionDepth);
}
}));
this.addRenderableWidget(new Button(BG_X + (rowWidth / 2) + LW_MOD, BG_Y + 85, INCR_W, 20, INCR, onPress -> {
this.explosionDepth++;
this.dirty = true;
this.depthBox.setValue("" + this.explosionDepth);
}));
/* Height Adj */
this.heightBox = this.addRenderableWidget(new EditBox(this.font, BG_X + (rowWidth / 2) + EB_MOD, BG_Y + 130, EDIT_BOX_WIDTH, 20, Component.literal("")));
this.heightBox.setValue("" + this.explosionHeight);
this.addRenderableWidget(new Button(BG_X + (rowWidth / 2) + FW_MOD, BG_Y + 130, DECR_W, 20, DECR, onPress -> {
if (this.explosionHeight > 0) {
this.explosionHeight--;
this.dirty = true;
this.heightBox.setValue("" + this.explosionHeight);
}
}));
this.addRenderableWidget(new Button(BG_X + (rowWidth / 2) + LW_MOD, BG_Y + 130, INCR_W, 20, INCR, onPress -> {
this.explosionHeight++;
this.dirty = true;
this.heightBox.setValue("" + this.explosionHeight);
}));
}
@Override
public void onClose() {
if (dirty) {
CompoundTag tag = Objects.requireNonNull(this.stack.getTag());
tag.putInt("explosionWidth", explosionWidth);
tag.putInt("explosionDepth", explosionDepth);
tag.putInt("explosionHeight", explosionHeight);
ChargedExplosives.getInstance().proxy.updateItemNbt(stack);
}
super.onClose();
}
@Override
public void tick() {
final int WHITE = 16777215;
final int RED = 16711680;
/* Tick each edit box */
try {
this.widthBox.tick();
int value = Integer.parseInt(this.widthBox.getValue());
this.widthBox.setTextColor(WHITE);
if (value != explosionWidth) {
this.explosionWidth = value;
this.dirty = true;
}
} catch (NumberFormatException ex) {
this.widthBox.setTextColor(RED);
}
try {
this.depthBox.tick();
int value = Integer.parseInt(this.depthBox.getValue());
this.depthBox.setTextColor(WHITE);
if (value != explosionDepth) {
this.explosionDepth = value;
this.dirty = true;
}
} catch (NumberFormatException ex) {
this.depthBox.setTextColor(RED);
}
try {
this.heightBox.tick();
int value = Integer.parseInt(this.heightBox.getValue());
this.heightBox.setTextColor(WHITE);
if (value != explosionHeight) {
this.explosionHeight = value;
this.dirty = true;
}
} catch (NumberFormatException ex) {
this.heightBox.setTextColor(RED);
}
}
private void tickEditBox(EditBox box, int comp, Function<Integer, Void> update) {
box.tick();
try {
int value = Integer.parseInt(box.getValue());
box.setTextColor(16777215);
if (value != comp) {
update.apply(value);
}
} catch (NumberFormatException ex) {
box.setTextColor(16711680);
}
}
@Override
public boolean shouldCloseOnEsc() {
return true;
}
@Override
public void render(@NotNull PoseStack stack, int mouseX, int mouseY, float partialTicks) {
final int BG_X = (this.width - TEXTURE_WIDTH) / 2;
final int BG_Y = (this.height - TEXTURE_HEIGHT) / 2;
this.renderBackground(stack);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE);
this.blit(stack, (this.width - TEXTURE_WIDTH) / 2, (this.height - TEXTURE_HEIGHT) / 2, 0, 0, TEXTURE_WIDTH, TEXTURE_WIDTH);
this.font.draw(stack, this.title, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.title) / 2), BG_Y + PADDING, 4210752);
/* Width Title */
this.font.draw(stack, this.widthTitle, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2), BG_Y + 20 + this.font.lineHeight, 7089453);
/* Depth Title */
this.font.draw(stack, this.depthTitle, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2), BG_Y + 65 + this.font.lineHeight, 7089453);
/* Height Title */
this.font.draw(stack, this.heightTitle, BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2), BG_Y + 110 + this.font.lineHeight, 7089453);
super.render(stack, mouseX, mouseY, partialTicks);
}
@Override
public boolean isPauseScreen() {
return false;
}
@Override
public void renderBackground(@NotNull PoseStack stack, int _unused) {
this.fillGradient(stack, 0, 0, this.width, this.height, -1072689136, -804253680);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ScreenEvent.BackgroundRendered(this, stack));
}
}

View file

@ -0,0 +1,18 @@
package com.oitsjustjose.charged_explosives.client.network;
import com.oitsjustjose.charged_explosives.client.ExplosionConfigScreen;
import com.oitsjustjose.charged_explosives.common.network.OpenGuiPacket;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class ClientOpenGuiPacket {
public static void handleClient(OpenGuiPacket pkt, Supplier<NetworkEvent.Context> ctx) {
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
ctx.get().enqueueWork(() -> Minecraft.getInstance().setScreen(new ExplosionConfigScreen(pkt.stack)));
ctx.get().setPacketHandled(true);
}
}
}

View file

@ -0,0 +1,35 @@
package com.oitsjustjose.charged_explosives.common;
import com.oitsjustjose.charged_explosives.common.network.NetworkManager;
import com.oitsjustjose.charged_explosives.common.network.OpenGuiPacket;
import com.oitsjustjose.charged_explosives.common.network.UpdateNbtPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.PacketDistributor;
import java.util.Optional;
public class CommonProxy {
public static NetworkManager netMgr = new NetworkManager("server");
public static int disc = 0;
public void init() {
CommonProxy.netMgr.networkWrapper.registerMessage(CommonProxy.disc++, OpenGuiPacket.class, OpenGuiPacket::encode, OpenGuiPacket::decode, OpenGuiPacket::handleServer);
CommonProxy.netMgr.networkWrapper.registerMessage(CommonProxy.disc++, UpdateNbtPacket.class, UpdateNbtPacket::encode, UpdateNbtPacket::decode, UpdateNbtPacket::handleServer, Optional.of(NetworkDirection.PLAY_TO_SERVER));
}
public void openExplosiveGui(Player player, ItemStack stack) {
if (player instanceof ServerPlayer spl) {
OpenGuiPacket pkt = new OpenGuiPacket(stack);
CommonProxy.netMgr.networkWrapper.send(PacketDistributor.PLAYER.with(() -> spl), pkt);
}
}
public void updateItemNbt(ItemStack stack) {
// NOOP
}
}

View file

@ -0,0 +1,20 @@
package com.oitsjustjose.charged_explosives.common;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentContents;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.contents.TranslatableContents;
public class Util {
public static Component translateOrFallback(String transKey) {
try {
return new TranslatableContents(transKey).resolve(null, null, 0);
} catch (CommandSyntaxException e) {
MutableComponent m = MutableComponent.create(ComponentContents.EMPTY);
m.append("Failed to resolve key ");
m.append(transKey);
return m;
}
}
}

View file

@ -0,0 +1,72 @@
package com.oitsjustjose.charged_explosives.common.blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.AttachFace;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBlock {
protected static final VoxelShape CEILING_AABB_X = Block.box(6.0D, 14.0D, 5.0D, 10.0D, 16.0D, 11.0D);
protected static final VoxelShape CEILING_AABB_Z = Block.box(5.0D, 14.0D, 6.0D, 11.0D, 16.0D, 10.0D);
protected static final VoxelShape FLOOR_AABB_X = Block.box(6.0D, 0.0D, 5.0D, 10.0D, 2.0D, 11.0D);
protected static final VoxelShape FLOOR_AABB_Z = Block.box(5.0D, 0.0D, 6.0D, 11.0D, 2.0D, 10.0D);
protected static final VoxelShape NORTH_AABB = Block.box(5.0D, 6.0D, 14.0D, 11.0D, 10.0D, 16.0D);
protected static final VoxelShape SOUTH_AABB = Block.box(5.0D, 6.0D, 0.0D, 11.0D, 10.0D, 2.0D);
protected static final VoxelShape WEST_AABB = Block.box(14.0D, 6.0D, 5.0D, 16.0D, 10.0D, 11.0D);
protected static final VoxelShape EAST_AABB = Block.box(0.0D, 6.0D, 5.0D, 2.0D, 10.0D, 11.0D);
public ChargedExplosiveBlock() {
super(BlockBehaviour.Properties.of(Material.EXPLOSIVE, MaterialColor.COLOR_RED)
.dynamicShape()
.noOcclusion()
.isValidSpawn((w, x, y, z) -> false)
.isRedstoneConductor((x, y, z) -> false)
.isSuffocating((x, y, z) -> false)
.isViewBlocking((x, y, z) -> false));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(FACE, AttachFace.WALL));
}
public @NotNull VoxelShape getShape(BlockState state, @NotNull BlockGetter getter, @NotNull BlockPos pos) {
Direction direction = state.getValue(FACING);
switch (state.getValue(FACE)) {
case FLOOR:
if (direction.getAxis() == Direction.Axis.X) {
return FLOOR_AABB_X;
}
return FLOOR_AABB_Z;
case WALL:
return switch (direction) {
case EAST -> EAST_AABB;
case WEST -> WEST_AABB;
case SOUTH -> SOUTH_AABB;
case DOWN -> FLOOR_AABB_X;
case UP -> CEILING_AABB_X;
case NORTH -> NORTH_AABB;
};
case CEILING:
default:
if (direction.getAxis() == Direction.Axis.X) {
return CEILING_AABB_X;
} else {
return CEILING_AABB_Z;
}
}
}
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> Builder) {
Builder.add(FACING, FACE);
}
}

View file

@ -0,0 +1,37 @@
package com.oitsjustjose.charged_explosives.common.items;
import com.oitsjustjose.charged_explosives.ChargedExplosives;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public class ChargedExplosiveItem extends BlockItem {
public ChargedExplosiveItem(Block block) {
super(block, new Item.Properties());
}
@Override
public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level level, Player player, @NotNull InteractionHand hand) {
// Set NBT if it hasn't been already
ItemStack stack = player.getItemInHand(hand);
CompoundTag tag = stack.getOrCreateTag();
UUID uuid;
if (tag.contains("explosive_id")) {
uuid = tag.getUUID("explosive_id");
} else {
uuid = UUID.randomUUID();
tag.putUUID("explosive_id", uuid);
}
ChargedExplosives.getInstance().proxy.openExplosiveGui(player, stack);
return super.use(level, player, hand);
}
}

View file

@ -0,0 +1,15 @@
package com.oitsjustjose.charged_explosives.common.network;
import com.oitsjustjose.charged_explosives.ChargedExplosives;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
public class NetworkManager {
public SimpleChannel networkWrapper;
private static final String PROTOCOL_VERSION = "1";
public NetworkManager(String nm) {
this.networkWrapper = NetworkRegistry.newSimpleChannel(new ResourceLocation(ChargedExplosives.MODID, nm), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
}
}

View file

@ -0,0 +1,32 @@
package com.oitsjustjose.charged_explosives.common.network;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier;
public class OpenGuiPacket {
public final ItemStack stack;
public OpenGuiPacket(FriendlyByteBuf buf) {
this.stack = buf.readItem();
}
public OpenGuiPacket(ItemStack stack) {
this.stack = stack;
}
public static OpenGuiPacket decode(FriendlyByteBuf buf) {
return new OpenGuiPacket(buf);
}
public static void encode(OpenGuiPacket pkt, FriendlyByteBuf buf) {
buf.writeItem(pkt.stack);
}
public void handleServer(Supplier<NetworkEvent.Context> ctx) {
ctx.get().setPacketHandled(true);
}
}

View file

@ -0,0 +1,67 @@
package com.oitsjustjose.charged_explosives.common.network;
import com.oitsjustjose.charged_explosives.ChargedExplosives;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.network.NetworkEvent;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;
public class UpdateNbtPacket {
public final ItemStack stack;
public UpdateNbtPacket(FriendlyByteBuf buf) {
this.stack = buf.readItem();
}
public UpdateNbtPacket(ItemStack stack) {
this.stack = stack;
}
public static UpdateNbtPacket decode(FriendlyByteBuf buf) {
return new UpdateNbtPacket(buf);
}
public static void encode(UpdateNbtPacket pkt, FriendlyByteBuf buf) {
buf.writeItem(pkt.stack);
}
public void handleClient(Supplier<NetworkEvent.Context> ctx) {
ctx.get().setPacketHandled(true);
}
public static void handleServer(UpdateNbtPacket pkt, Supplier<NetworkEvent.Context> ctx) {
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.SERVER) {
ctx.get().enqueueWork(() -> {
if (!pkt.stack.hasTag()) {
ChargedExplosives.getInstance().LOGGER.warn("ItemStack from packet had NO NBT to update with. NOOP");
return;
}
CompoundTag newTag = Objects.requireNonNull(pkt.stack.getTag());
// Search for the item to update
Optional<ItemStack> stack = Objects.requireNonNull(ctx.get().getSender()).getInventory().items.stream().filter(x -> {
return x.hasTag()
&& x.getTag() != null
&& x.getTag().contains("explosive_id")
&& x.getTag().getUUID("explosive_id") == newTag.getUUID("explosive_id");
}).findFirst();
if (stack.isPresent()) {
// We know there's a tag present because we used it earlier in the filter()
CompoundTag tag = Objects.requireNonNull(stack.get().getTag());
tag.putInt("explosionWidth", newTag.getInt("explosionWidth"));
tag.putInt("explosionDepth", newTag.getInt("explosionDepth"));
tag.putInt("explosionHeight", newTag.getInt("explosionHeight"));
}
});
ctx.get().setPacketHandled(true);
}
}
}

View file

@ -0,0 +1,18 @@
package com.oitsjustjose.charged_explosives.common.registry;
import com.oitsjustjose.charged_explosives.ChargedExplosives;
import com.oitsjustjose.charged_explosives.common.blocks.ChargedExplosiveBlock;
import com.oitsjustjose.charged_explosives.common.items.ChargedExplosiveItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class Registry {
public final DeferredRegister<Block> BlockRegistry = DeferredRegister.create(ForgeRegistries.BLOCKS, ChargedExplosives.MODID);
public final DeferredRegister<Item> ItemRegistry = DeferredRegister.create(ForgeRegistries.ITEMS, ChargedExplosives.MODID);
public final RegistryObject<Block> CeBlock = BlockRegistry.register("charged_explosive", ChargedExplosiveBlock::new);
public final RegistryObject<Item> CeItem = ItemRegistry.register("charged_explosive", () -> new ChargedExplosiveItem(CeBlock.get()));
}

View file

@ -0,0 +1,26 @@
modLoader="javafml"
loaderVersion="[43,)"
license="GNU GPLv3"
[[mods]]
modId="charged_explosives"
version="${file.jarVersion}"
displayName="Charged Explosives"
displayURL="https://github.com/oitsjustjose/Charged-Explosives"
credits="Rorax for the assets!"
authors="oitsjustjose"
description='''A small mod adding in configurable charged explosives'''
[[dependencies.charged_explosives]]
modId="forge"
mandatory=true
versionRange="[43,)"
ordering="NONE"
side="BOTH"
[[dependencies.charged_explosives]]
modId="minecraft"
mandatory=true
versionRange="[1.19,)"
ordering="NONE"
side="BOTH"

View file

@ -0,0 +1,58 @@
{
"variants": {
"face=ceiling,facing=east": {
"model": "charged_explosives:item/charged_explosive",
"x": 180,
"y": 270
},
"face=ceiling,facing=north": {
"model": "charged_explosives:item/charged_explosive",
"x": 180,
"y": 180
},
"face=ceiling,facing=south": {
"model": "charged_explosives:item/charged_explosive",
"x": 180
},
"face=ceiling,facing=west": {
"model": "charged_explosives:item/charged_explosive",
"x": 180,
"y": 90
},
"face=floor,facing=east": {
"model": "charged_explosives:item/charged_explosive",
"y": 90
},
"face=floor,facing=north": {
"model": "charged_explosives:item/charged_explosive"
},
"face=floor,facing=south": {
"model": "charged_explosives:item/charged_explosive",
"y": 180
},
"face=floor,facing=west": {
"model": "charged_explosives:item/charged_explosive",
"y": 270
},
"face=wall,facing=east": {
"model": "charged_explosives:item/charged_explosive",
"x": 90,
"y": 90
},
"face=wall,facing=north": {
"model": "charged_explosives:item/charged_explosive",
"x": 90
},
"face=wall,facing=south": {
"model": "charged_explosives:item/charged_explosive",
"x": 90,
"y": 180
},
"face=wall,facing=west": {
"model": "charged_explosives:item/charged_explosive",
"x": 90,
"y": 270
}
}
}

View file

@ -0,0 +1,4 @@
{
"enchantment.vtweaks.lumbering": "Holzfällen",
"enchantment.vtweaks.imperishable": "Widerstandsfähig"
}

View file

@ -0,0 +1,6 @@
{
"charged_explosives.explosion.configuration.title": "Configure Blast",
"charged_explosives.explosion.width.title": "Explosion Width:",
"charged_explosives.explosion.height.title": "Explosion Height:",
"charged_explosives.explosion.depth.title": "Explosion Depth:"
}

View file

@ -0,0 +1,21 @@
{
"enchantment.vtweaks.lumbering": "批量砍伐",
"enchantment.vtweaks.imperishable": "不灭",
"enchantment.vtweaks.lumbering.desc": "§3潜行状态下:§r\n 破坏组成树的任意木方块可令整颗树倒下。\n §4§l非树木亦有效果§r",
"enchantment.vtweaks.imperishable.desc": "保护工具或护甲,令其免遭破坏,\n 即§l在物品得到修理之前\n 禁用其功能。§r",
"vtweaks:lumbering.desc": "潜行破坏树干方块可砍倒整颗树。非树木亦有效果",
"vtweaks:imperishable.desc": "令工具或护甲免遭破坏,在修理前禁用其功能",
"vtweaks.death.message": "你死在了§e[X:%s, Y:%s, Z:%s]§r",
"vtweaks.man.pants": "§5半身裤§r",
"vtweaks.mighty.challenger.mob": "强大之%s",
"vtweaks.hungry.challenger.mob": "饥饿之%s",
"vtweaks.ranger.challenger.mob": "射手之%s",
"vtweaks.arcane.challenger.mob": "奥术之%s",
"vtweaks.pyro.challenger.mob": "纵火之%s",
"vtweaks.zistonian.challenger.mob": "反暴之%s",
"vtweaks.reinforced.challenger.mob": "硬化之%s",
"vtweaks.agile.challenger.mob": "灵活之%s",
"vtweaks.intro.link": "V-Tweaks 在线维基",
"vtweaks.intro.message": "欢迎你!由于这个世界存档第一次使用V-Tweaks,特提供在线维基页面链接,如有兴趣可前往了解 - 别忘了,有些功能是可以禁用掉的!",
"vtweaks.tool.damaged": "§4§l你的工具受损过于严重,无法使用!§r"
}

View file

@ -0,0 +1,45 @@
{
"credit": "Rorax :)",
"texture_size": [4, 4],
"textures": {
"0": "charged_explosives:block/charged_explosive_main",
"1": "charged_explosives:block/shaped_charge_light",
"particle": "charged_explosives:block/charged_explosive_main"
},
"elements": [
{
"name": "charged_explosive_main",
"from": [2, 0, 4],
"to": [14, 3, 12],
"faces": {
"north": {"uv": [0, 10, 6, 13], "texture": "#0"},
"east": {"uv": [6, 10, 10, 13], "texture": "#0"},
"south": {"uv": [0, 13, 6, 16], "texture": "#0"},
"west": {"uv": [6, 13, 10, 16], "texture": "#0"},
"up": {"uv": [0, 2, 6, 10], "texture": "#0"},
"down": {"uv": [6, 2, 12, 10], "texture": "#0"}
}
},
{
"name": "shaped_charge_light",
"from": [10, 3, 7],
"to": [12, 4, 9],
"faces": {
"north": {"uv": [8, 0, 16, 4], "texture": "#1"},
"east": {"uv": [8, 8, 16, 12], "texture": "#1"},
"south": {"uv": [8, 8, 16, 4], "texture": "#1"},
"west": {"uv": [8, 12, 16, 16], "texture": "#1"},
"up": {"uv": [0, 0, 8, 8], "texture": "#1"},
"down": {"uv": [0, 8, 8, 16], "texture": "#1"}
}
}
],
"groups": [
{
"name": "shaped charge",
"origin": [0, 0, 0],
"color": 0,
"children": [0, 1]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -0,0 +1,6 @@
{
"pack": {
"description": "Charged Explosives' Resources",
"pack_format": 10
}
}