added dynamite (missing textures)
This commit is contained in:
parent
8ed0394fdd
commit
79c268bc5b
@ -38,7 +38,7 @@ mod_name=Compressed TNT
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=All Rights Reserved
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=0.5.0
|
||||
mod_version=0.6.0
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
@ -30,6 +30,7 @@ public class creativeTab {
|
||||
output.accept(items.TNT_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());
|
||||
|
||||
public static void register(IEventBus bus) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.math.Axis;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@ -14,7 +14,7 @@ import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class clusterTNTRenderer extends EntityRenderer<ClusterPrimedTNT> {
|
||||
public class clusterTNTRenderer extends EntityRenderer<basePrimedTNT> {
|
||||
private final BlockRenderDispatcher blockRenderer;
|
||||
|
||||
public clusterTNTRenderer(EntityRendererProvider.Context pContext) {
|
||||
@ -23,7 +23,7 @@ public class clusterTNTRenderer extends EntityRenderer<ClusterPrimedTNT> {
|
||||
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.translate(0.0F, 0.5F, 0.0F);
|
||||
int i = pEntity.getFuse();
|
||||
@ -47,7 +47,7 @@ public class clusterTNTRenderer extends EntityRenderer<ClusterPrimedTNT> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.jenny.compressedtnt.entities.arrows.*;
|
||||
import com.jenny.compressedtnt.entities.client.BaseTNTRenderer;
|
||||
import com.jenny.compressedtnt.entities.client.TNTArrowRenderer;
|
||||
import com.jenny.compressedtnt.entities.client.clusterTNTRenderer;
|
||||
import com.jenny.compressedtnt.entities.throwable.dynamite;
|
||||
import com.jenny.compressedtnt.entities.tnt.*;
|
||||
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
@ -52,6 +53,10 @@ public class entities {
|
||||
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) {
|
||||
ENTITY_TYPES.register(eventBus);
|
||||
}
|
||||
@ -66,5 +71,7 @@ public class entities {
|
||||
EntityRenderers.register(ARROW_TNT.get(), TNTArrowRenderer::new);
|
||||
EntityRenderers.register(ARROW_CONCUSSIVE.get(), TNTArrowRenderer::new);
|
||||
EntityRenderers.register(ARROW_CARPET.get(), TNTArrowRenderer::new);
|
||||
|
||||
EntityRenderers.register(DYNAMITE.get(), clusterTNTRenderer::new);
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
54
src/main/java/com/jenny/compressedtnt/items/Dynamite.java
Normal file
54
src/main/java/com/jenny/compressedtnt/items/Dynamite.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ public class items {
|
||||
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> 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) {
|
||||
ITEMS.register(bus);
|
||||
|
@ -14,6 +14,7 @@
|
||||
"item.compressedtnt.arrow_tnt": "TNT 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",
|
||||
@ -24,5 +25,6 @@
|
||||
|
||||
"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.arrow_carpet": "splits into multiple TNT arrows when it starts falling",
|
||||
"tooltip.compressedtnt.dynamite": "TNT, but throwable"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user