Compare commits

..

4 Commits

16 changed files with 317 additions and 21 deletions

View File

@ -1,5 +1,7 @@
package com.jenny.compressedtnt.blocks; package com.jenny.compressedtnt.blocks;
import com.jenny.compressedtnt.items.BlockItemTooltip;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
@ -17,37 +19,37 @@ public class blocks {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
public static final RegistryObject<strongerTNTBlock> TNT_8 = BLOCKS.register("tnt_8", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 8.0f, 80)); public static final RegistryObject<strongerTNTBlock> TNT_8 = BLOCKS.register("tnt_8", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 8.0f, 80));
public static final RegistryObject<Item> TNT_8_ITEM = ITEMS.register("tnt_8", () -> new BlockItem(TNT_8.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_8_ITEM = ITEMS.register("tnt_8", () -> new BlockItemTooltip(TNT_8.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_16 = BLOCKS.register("tnt_16", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 16.0f, 80)); public static final RegistryObject<Block> TNT_16 = BLOCKS.register("tnt_16", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 16.0f, 80));
public static final RegistryObject<Item> TNT_16_ITEM = ITEMS.register("tnt_16", () -> new BlockItem(TNT_16.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_16_ITEM = ITEMS.register("tnt_16", () -> new BlockItemTooltip(TNT_16.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_32 = BLOCKS.register("tnt_32", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 32.0f, 80)); public static final RegistryObject<Block> TNT_32 = BLOCKS.register("tnt_32", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 32.0f, 80));
public static final RegistryObject<Item> TNT_32_ITEM = ITEMS.register("tnt_32", () -> new BlockItem(TNT_32.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_32_ITEM = ITEMS.register("tnt_32", () -> new BlockItemTooltip(TNT_32.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_64 = BLOCKS.register("tnt_64", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 64.0f, 80)); public static final RegistryObject<Block> TNT_64 = BLOCKS.register("tnt_64", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 64.0f, 80));
public static final RegistryObject<Item> TNT_64_ITEM = ITEMS.register("tnt_64", () -> new BlockItem(TNT_64.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_64_ITEM = ITEMS.register("tnt_64", () -> new BlockItemTooltip(TNT_64.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_128 = BLOCKS.register("tnt_128", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 128.0f, 80)); public static final RegistryObject<Block> TNT_128 = BLOCKS.register("tnt_128", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 128.0f, 80));
public static final RegistryObject<Item> TNT_128_ITEM = ITEMS.register("tnt_128", () -> new BlockItem(TNT_128.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_128_ITEM = ITEMS.register("tnt_128", () -> new BlockItemTooltip(TNT_128.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_CLUSTER_2 = BLOCKS.register("tnt_cluster_2", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 2, 10)); public static final RegistryObject<Block> TNT_CLUSTER_2 = BLOCKS.register("tnt_cluster_2", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 2, 10));
public static final RegistryObject<Item> TNT_CLUSTER_2_ITEM = ITEMS.register("tnt_cluster_2", () -> new BlockItem(TNT_CLUSTER_2.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_CLUSTER_2_ITEM = ITEMS.register("tnt_cluster_2", () -> new BlockItemTooltip(TNT_CLUSTER_2.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_CLUSTER_4 = BLOCKS.register("tnt_cluster_4", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 4, 10)); public static final RegistryObject<Block> TNT_CLUSTER_4 = BLOCKS.register("tnt_cluster_4", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 4, 10));
public static final RegistryObject<Item> TNT_CLUSTER_4_ITEM = ITEMS.register("tnt_cluster_4", () -> new BlockItem(TNT_CLUSTER_4.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_CLUSTER_4_ITEM = ITEMS.register("tnt_cluster_4", () -> new BlockItemTooltip(TNT_CLUSTER_4.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_CLUSTER_8 = BLOCKS.register("tnt_cluster_8", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 8, 10)); public static final RegistryObject<Block> TNT_CLUSTER_8 = BLOCKS.register("tnt_cluster_8", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 8, 10));
public static final RegistryObject<Item> TNT_CLUSTER_8_ITEM = ITEMS.register("tnt_cluster_8", () -> new BlockItem(TNT_CLUSTER_8.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_CLUSTER_8_ITEM = ITEMS.register("tnt_cluster_8", () -> new BlockItemTooltip(TNT_CLUSTER_8.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_HOMING= BLOCKS.register("tnt_homing", () -> new homingTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 1)); public static final RegistryObject<Block> TNT_HOMING= BLOCKS.register("tnt_homing", () -> new homingTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 1));
public static final RegistryObject<Item> TNT_HOMING_ITEM = ITEMS.register("tnt_homing", () -> new BlockItem(TNT_HOMING.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_HOMING_ITEM = ITEMS.register("tnt_homing", () -> new BlockItemTooltip(TNT_HOMING.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_BLACK_HOLE= BLOCKS.register("tnt_black_hole", () -> new blackHoleTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 1)); public static final RegistryObject<Block> TNT_BLACK_HOLE= BLOCKS.register("tnt_black_hole", () -> new blackHoleTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 1));
public static final RegistryObject<Item> TNT_BLACK_HOLE_ITEM = ITEMS.register("tnt_black_hole", () -> new BlockItem(TNT_BLACK_HOLE.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_BLACK_HOLE_ITEM = ITEMS.register("tnt_black_hole", () -> new BlockItemTooltip(TNT_BLACK_HOLE.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_CLAYMORE= BLOCKS.register("tnt_claymore", () -> new claymoreTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 2.0f, 20, 256)); public static final RegistryObject<Block> TNT_CLAYMORE= BLOCKS.register("tnt_claymore", () -> new claymoreTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 2.0f, 20, 256));
public static final RegistryObject<Item> TNT_CLAYMORE_ITEM = ITEMS.register("tnt_claymore", () -> new BlockItem(TNT_CLAYMORE.get(), new Item.Properties())); public static final RegistryObject<Item> TNT_CLAYMORE_ITEM = ITEMS.register("tnt_claymore", () -> new BlockItemTooltip(TNT_CLAYMORE.get(), new Item.Properties()));
public static void register(IEventBus bus) { public static void register(IEventBus bus) {

View File

@ -29,6 +29,8 @@ public class creativeTab {
output.accept(blocks.TNT_CLAYMORE.get()); output.accept(blocks.TNT_CLAYMORE.get());
output.accept(items.TNT_ARROW.get()); output.accept(items.TNT_ARROW.get());
output.accept(items.CONCUSSIVE_ARROW.get()); output.accept(items.CONCUSSIVE_ARROW.get());
output.accept(items.CARPET_ARROW.get());
output.accept(items.DYNAMITE.get());
}).title(Component.literal("Compressed TNT")).build()); }).title(Component.literal("Compressed TNT")).build());
public static void register(IEventBus bus) { public static void register(IEventBus bus) {

View File

@ -21,6 +21,7 @@ public class ModItemModelProvider extends ItemModelProvider {
protected void registerModels() { protected void registerModels() {
simpleItem(items.TNT_ARROW); simpleItem(items.TNT_ARROW);
simpleItem(items.CONCUSSIVE_ARROW); simpleItem(items.CONCUSSIVE_ARROW);
simpleItem(items.CARPET_ARROW);
} }
private ItemModelBuilder simpleItem(RegistryObject<Item> item) { private ItemModelBuilder simpleItem(RegistryObject<Item> item) {

View File

@ -0,0 +1,57 @@
package com.jenny.compressedtnt.entities.arrows;
import com.jenny.compressedtnt.entities.entities;
import com.jenny.compressedtnt.items.items;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
public class carpetArrow extends baseArrow {
private int tick = 0;
private Vec3 pos = position();
public final int childCount = 32;
public carpetArrow(EntityType<carpetArrow> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
}
public carpetArrow(Level pLevel, LivingEntity pShooter) {
super(pLevel, pShooter, entities.ARROW_CARPET.get());
}
@Override
public void tick() {
pos = position();
super.tick();
if (level().isClientSide()) {
level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), 0.0D, 0.0D, 0.0D);
}
tick++;
if (pos.y > position().y) {
spawnChildren(childCount);
discard();
}
}
protected void spawnChildren(int count) {
Vec3 delta = getDeltaMovement();
RandomSource rng = level().getRandom();
for (int i = 0; i < count; i++) {
concussiveArrow arrow = new concussiveArrow(entities.ARROW_CONCUSSIVE.get(), level());
Vec3 move = delta.add((float) rng.nextInt(-10, 11) / 10, 0, (float) rng.nextInt(-10, 11) / 10);
arrow.setPos(position());
arrow.setDeltaMovement(delta.add(move.multiply(0.2, 0, 0.2)));
level().addFreshEntity(arrow);
}
}
@NotNull
protected ItemStack getPickupItem() {
return new ItemStack(items.CARPET_ARROW.get());
}
}

View File

@ -1,6 +1,6 @@
package com.jenny.compressedtnt.entities.client; package com.jenny.compressedtnt.entities.client;
import com.jenny.compressedtnt.entities.tnt.ClusterPrimedTNT; import com.jenny.compressedtnt.entities.tnt.basePrimedTNT;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis; import com.mojang.math.Axis;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
@ -14,7 +14,7 @@ import net.minecraft.util.Mth;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class clusterTNTRenderer extends EntityRenderer<ClusterPrimedTNT> { public class clusterTNTRenderer extends EntityRenderer<basePrimedTNT> {
private final BlockRenderDispatcher blockRenderer; private final BlockRenderDispatcher blockRenderer;
public clusterTNTRenderer(EntityRendererProvider.Context pContext) { public clusterTNTRenderer(EntityRendererProvider.Context pContext) {
@ -23,7 +23,7 @@ public class clusterTNTRenderer extends EntityRenderer<ClusterPrimedTNT> {
this.blockRenderer = pContext.getBlockRenderDispatcher(); this.blockRenderer = pContext.getBlockRenderDispatcher();
} }
public void render(ClusterPrimedTNT pEntity, float pEntityYaw, float pPartialTicks, PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight) { public void render(basePrimedTNT pEntity, float pEntityYaw, float pPartialTicks, PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight) {
pPoseStack.pushPose(); pPoseStack.pushPose();
pPoseStack.translate(0.0F, 0.5F, 0.0F); pPoseStack.translate(0.0F, 0.5F, 0.0F);
int i = pEntity.getFuse(); int i = pEntity.getFuse();
@ -47,7 +47,7 @@ public class clusterTNTRenderer extends EntityRenderer<ClusterPrimedTNT> {
super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight); super.render(pEntity, pEntityYaw, pPartialTicks, pPoseStack, pBuffer, pPackedLight);
} }
public @NotNull ResourceLocation getTextureLocation(@NotNull ClusterPrimedTNT pEntity) { public @NotNull ResourceLocation getTextureLocation(@NotNull basePrimedTNT pEntity) {
return TextureAtlas.LOCATION_BLOCKS; return TextureAtlas.LOCATION_BLOCKS;
} }
} }

View File

@ -4,6 +4,7 @@ import com.jenny.compressedtnt.entities.arrows.*;
import com.jenny.compressedtnt.entities.client.BaseTNTRenderer; import com.jenny.compressedtnt.entities.client.BaseTNTRenderer;
import com.jenny.compressedtnt.entities.client.TNTArrowRenderer; import com.jenny.compressedtnt.entities.client.TNTArrowRenderer;
import com.jenny.compressedtnt.entities.client.clusterTNTRenderer; import com.jenny.compressedtnt.entities.client.clusterTNTRenderer;
import com.jenny.compressedtnt.entities.throwable.dynamite;
import com.jenny.compressedtnt.entities.tnt.*; import com.jenny.compressedtnt.entities.tnt.*;
import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.client.renderer.entity.EntityRenderers;
@ -48,6 +49,14 @@ public class entities {
ENTITY_TYPES.register("arrow_concussive", () -> EntityType.Builder.<concussiveArrow>of(concussiveArrow::new, MobCategory.MISC) ENTITY_TYPES.register("arrow_concussive", () -> EntityType.Builder.<concussiveArrow>of(concussiveArrow::new, MobCategory.MISC)
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_concussive")); .sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_concussive"));
public static final RegistryObject<EntityType<carpetArrow>> ARROW_CARPET =
ENTITY_TYPES.register("arrow_carpet", () -> EntityType.Builder.<carpetArrow>of(carpetArrow::new, MobCategory.MISC)
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_carpet"));
public static final RegistryObject<EntityType<dynamite>> DYNAMITE =
ENTITY_TYPES.register("dynamite", () -> EntityType.Builder.<dynamite>of(dynamite::new, MobCategory.MISC)
.sized(0.48F, 0.48F).clientTrackingRange(64).build("dynamite"));
public static void register(IEventBus eventBus) { public static void register(IEventBus eventBus) {
ENTITY_TYPES.register(eventBus); ENTITY_TYPES.register(eventBus);
} }
@ -61,5 +70,8 @@ public class entities {
EntityRenderers.register(ARROW_TNT.get(), TNTArrowRenderer::new); EntityRenderers.register(ARROW_TNT.get(), TNTArrowRenderer::new);
EntityRenderers.register(ARROW_CONCUSSIVE.get(), TNTArrowRenderer::new); EntityRenderers.register(ARROW_CONCUSSIVE.get(), TNTArrowRenderer::new);
EntityRenderers.register(ARROW_CARPET.get(), TNTArrowRenderer::new);
EntityRenderers.register(DYNAMITE.get(), clusterTNTRenderer::new);
} }
} }

View File

@ -0,0 +1,62 @@
package com.jenny.compressedtnt.entities.throwable;
import com.jenny.compressedtnt.entities.entities;
import com.jenny.compressedtnt.entities.tnt.basePrimedTNT;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nullable;
public class dynamite extends basePrimedTNT {
public dynamite (Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse) {
super(entities.DYNAMITE.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power, "dynamite");
}
public dynamite(EntityType<dynamite> entityType, Level level) {
super(entityType, level, null);
this.setRenderID("dynamite");
}
@Override
public void tick() {
if (!this.isNoGravity()) {
this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
}
Vec3 beforeMove = getDeltaMovement();
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
if (this.onGround()) {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, 0, 0.7D).add(0, (-beforeMove.y) * 0.5, 0));
}
int i = this.getFuse() - 1;
this.setFuse(i);
if (i <= 0) {
this.discard();
if (!this.level().isClientSide) {
this.explode();
}
} else {
this.updateInWaterStateAndDoFluidPushing();
if (this.level().isClientSide) {
this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D);
}
}
}
public void shootFromRotation(Entity pShooter, float pX, float pY, float pZ, float pVelocity) {
float f = -Mth.sin(pY * ((float)Math.PI / 180F)) * Mth.cos(pX * ((float)Math.PI / 180F));
float f1 = -Mth.sin((pX + pZ) * ((float)Math.PI / 180F));
float f2 = Mth.cos(pY * ((float)Math.PI / 180F)) * Mth.cos(pX * ((float)Math.PI / 180F));
Vec3 vec = new Vec3(f, f1, f2).multiply(pVelocity, pVelocity, pVelocity);
this.setDeltaMovement(vec);
Vec3 vec3 = pShooter.getDeltaMovement();
this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, pShooter.onGround() ? 0.0D : vec3.y, vec3.z));
}
}

View File

@ -0,0 +1,38 @@
package com.jenny.compressedtnt.items;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import static com.jenny.compressedtnt.Compressedtnt.MODID;
public abstract class ArrowAbstract extends ArrowItem {
public ArrowAbstract(Item.Properties properties){
super(properties);
}
@Override
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
String key = String.format("tooltip.%s.%s", MODID, this);
MutableComponent toolTip = Component.translatable(key);
if (!toolTip.getString().equals(key)) {
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE));
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
}
}
@Override
@NotNull
public abstract AbstractArrow createArrow(@NotNull Level pLevel, @NotNull ItemStack pStack, @NotNull LivingEntity pShooter);
}

View File

@ -0,0 +1,20 @@
package com.jenny.compressedtnt.items;
import com.jenny.compressedtnt.entities.arrows.carpetArrow;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
public class ArrowCarpet extends ArrowAbstract {
public ArrowCarpet(Properties properties){
super(properties);
}
@Override
@NotNull
public AbstractArrow createArrow(@NotNull Level pLevel, @NotNull ItemStack pStack, @NotNull LivingEntity pShooter) {
return new carpetArrow(pLevel, pShooter);
}
}

View File

@ -3,13 +3,12 @@ package com.jenny.compressedtnt.items;
import com.jenny.compressedtnt.entities.arrows.concussiveArrow; import com.jenny.compressedtnt.entities.arrows.concussiveArrow;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class ArrowConcussive extends ArrowItem { public class ArrowConcussive extends ArrowAbstract {
public ArrowConcussive(Item.Properties properties){ public ArrowConcussive(Item.Properties properties){
super(properties); super(properties);
} }

View File

@ -3,13 +3,12 @@ package com.jenny.compressedtnt.items;
import com.jenny.compressedtnt.entities.arrows.tntArrow; import com.jenny.compressedtnt.entities.arrows.tntArrow;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class ArrowTNT extends ArrowItem { public class ArrowTNT extends ArrowAbstract {
public ArrowTNT(Item.Properties properties){ public ArrowTNT(Item.Properties properties){
super(properties); super(properties);
} }

View File

@ -0,0 +1,33 @@
package com.jenny.compressedtnt.items;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import static com.jenny.compressedtnt.Compressedtnt.MODID;
public class BlockItemTooltip extends BlockItem {
public BlockItemTooltip(Block pBlock, Item.Properties pProperties){
super(pBlock, pProperties);
}
@Override
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
String key = String.format("tooltip.%s.%s", MODID, this);
MutableComponent toolTip = Component.translatable(key);
if (!toolTip.getString().equals(key)) {
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE));
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
}
}
}

View File

@ -0,0 +1,54 @@
package com.jenny.compressedtnt.items;
import com.jenny.compressedtnt.entities.throwable.dynamite;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import static com.jenny.compressedtnt.Compressedtnt.MODID;
public class Dynamite extends Item {
public Dynamite(Item.Properties pProperties) {
super(pProperties);
}
@Override
@NotNull
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, @NotNull InteractionHand pHand) {
ItemStack itemstack = pPlayer.getItemInHand(pHand);
if (!pLevel.isClientSide) {
dynamite d = new dynamite(pLevel, pPlayer.getX(), pPlayer.getY(), pPlayer.getZ(), pPlayer, 4, 80);
d.shootFromRotation(pPlayer, pPlayer.getXRot(), pPlayer.getYRot(), -20.0F, 0.5F);
pLevel.addFreshEntity(d);
}
pPlayer.awardStat(Stats.ITEM_USED.get(this));
if (!pPlayer.getAbilities().instabuild) {
itemstack.shrink(1);
}
return InteractionResultHolder.sidedSuccess(itemstack, pLevel.isClientSide());
}
@Override
public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List<Component> pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) {
String key = String.format("tooltip.%s.%s", MODID, this);
MutableComponent toolTip = Component.translatable(key);
if (!toolTip.getString().equals(key)) {
pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE));
super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
}
}
}

View File

@ -13,6 +13,8 @@ public class items {
public static final RegistryObject<Item> TNT_ARROW = ITEMS.register("arrow_tnt", () -> new ArrowTNT(new Item.Properties())); public static final RegistryObject<Item> TNT_ARROW = ITEMS.register("arrow_tnt", () -> new ArrowTNT(new Item.Properties()));
public static final RegistryObject<Item> CONCUSSIVE_ARROW = ITEMS.register("arrow_concussive", () -> new ArrowConcussive(new Item.Properties())); public static final RegistryObject<Item> CONCUSSIVE_ARROW = ITEMS.register("arrow_concussive", () -> new ArrowConcussive(new Item.Properties()));
public static final RegistryObject<Item> CARPET_ARROW = ITEMS.register("arrow_carpet", () -> new ArrowCarpet(new Item.Properties()));
public static final RegistryObject<Item> DYNAMITE = ITEMS.register("dynamite", () -> new Dynamite(new Item.Properties()));
public static void register(IEventBus bus) { public static void register(IEventBus bus) {
ITEMS.register(bus); ITEMS.register(bus);

View File

@ -12,5 +12,19 @@
"block.compressedtnt.tnt_claymore": "Claymore TNT", "block.compressedtnt.tnt_claymore": "Claymore TNT",
"item.compressedtnt.arrow_tnt": "TNT Arrow", "item.compressedtnt.arrow_tnt": "TNT Arrow",
"item.compressedtnt.arrow_concussive": "Concussive Arrow" "item.compressedtnt.arrow_concussive": "Concussive Arrow",
"item.compressedtnt.arrow_carpet": "Carpet Bombing Arrow",
"item.compressedtnt.dynamite": "Dynamite",
"tooltip.compressedtnt.tnt_cluster_2": "splits into 2 small TNTs",
"tooltip.compressedtnt.tnt_cluster_4": "splits into 4 small TNTs",
"tooltip.compressedtnt.tnt_cluster_8": "splits into 8 small TNTs",
"tooltip.compressedtnt.tnt_homing": "follows the closest entity",
"tooltip.compressedtnt.tnt_black_hole": "pulls all entities towards itself",
"tooltip.compressedtnt.tnt_claymore": "throws arrows into all direcctions upon explosion",
"tooltip.compressedtnt.arrow_tnt": "explodes on impact",
"tooltip.compressedtnt.arrow_concussive": "explodes on impact without block damage",
"tooltip.compressedtnt.arrow_carpet": "splits into multiple TNT arrows when it starts falling",
"tooltip.compressedtnt.dynamite": "TNT, but throwable"
} }

View File

@ -1,6 +1,7 @@
{ {
"values": [ "values": [
"compressedtnt:arrow_tnt", "compressedtnt:arrow_tnt",
"compressedtnt:arrow_concussive" "compressedtnt:arrow_concussive",
"compressedtnt:arrow_carpet"
] ]
} }