Compare commits
No commits in common. "2325f0ce1846eff4c25de672016487cb8c09d2a5" and "b6f950b788b2313b93d519b52b604b00343f82fd" have entirely different histories.
2325f0ce18
...
b6f950b788
@ -1,59 +0,0 @@
|
|||||||
package com.jenny.compressedtnt.blocks;
|
|
||||||
|
|
||||||
import com.jenny.compressedtnt.entities.blackHolePrimedTNT;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.sounds.SoundEvents;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.level.Explosion;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.TntBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class blackHoleTNTBlock extends TntBlock {
|
|
||||||
public final float pRadius, speed;
|
|
||||||
public final int fuseTime;
|
|
||||||
|
|
||||||
public blackHoleTNTBlock(Properties p_57422_, float pRadius, int fuseTime, float speed) {
|
|
||||||
super(p_57422_);
|
|
||||||
this.pRadius = pRadius;
|
|
||||||
this.fuseTime = fuseTime;
|
|
||||||
this.speed = speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCaughtFire(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) {
|
|
||||||
explode(world, pos, igniter, this.pRadius, this.fuseTime, this.speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static void explode(Level p_57434_, BlockPos p_57435_, float pRadius, int fuseTime, float speed) {
|
|
||||||
explode(p_57434_, p_57435_, (LivingEntity)null, pRadius, fuseTime, speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static void explode(Level level, BlockPos blockPos, @Nullable LivingEntity entity, float pRadius, int fuseTime, float speed) {
|
|
||||||
if (!level.isClientSide) {
|
|
||||||
blackHolePrimedTNT primedtnt = new blackHolePrimedTNT(level, (double)blockPos.getX() + (double)0.5F, (double)blockPos.getY(), (double)blockPos.getZ() + (double)0.5F, entity, pRadius, fuseTime, speed);
|
|
||||||
level.addFreshEntity(primedtnt);
|
|
||||||
level.playSound((Player)null, primedtnt.getX(), primedtnt.getY(), primedtnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
||||||
level.gameEvent(entity, GameEvent.PRIME_FUSE, blockPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void wasExploded(Level level, BlockPos blockPos, Explosion pExplosion) {
|
|
||||||
if (!level.isClientSide) {
|
|
||||||
blackHolePrimedTNT primedtnt = new blackHolePrimedTNT(level, (double) blockPos.getX() + (double) 0.5F, (double) blockPos.getY(), (double) blockPos.getZ() + (double) 0.5F, pExplosion.getIndirectSourceEntity(), pRadius, fuseTime, speed);
|
|
||||||
int i = primedtnt.getFuse();
|
|
||||||
primedtnt.setFuse((short) (level.random.nextInt(i / 4) + i / 8));
|
|
||||||
level.addFreshEntity(primedtnt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -43,10 +43,6 @@ public class blocks {
|
|||||||
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 BlockItem(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<Item> TNT_BLACK_HOLE_ITEM = ITEMS.register("tnt_black_hole", () -> new BlockItem(TNT_BLACK_HOLE.get(), new Item.Properties()));
|
|
||||||
|
|
||||||
|
|
||||||
public static void register(IEventBus bus) {
|
public static void register(IEventBus bus) {
|
||||||
BLOCKS.register(bus);
|
BLOCKS.register(bus);
|
||||||
ITEMS.register(bus);
|
ITEMS.register(bus);
|
||||||
|
@ -24,7 +24,6 @@ public class creativeTab {
|
|||||||
output.accept(blocks.TNT_CLUSTER_4.get());
|
output.accept(blocks.TNT_CLUSTER_4.get());
|
||||||
output.accept(blocks.TNT_CLUSTER_8.get());
|
output.accept(blocks.TNT_CLUSTER_8.get());
|
||||||
output.accept(blocks.TNT_HOMING.get());
|
output.accept(blocks.TNT_HOMING.get());
|
||||||
output.accept(blocks.TNT_BLACK_HOLE.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) {
|
||||||
|
@ -1,97 +0,0 @@
|
|||||||
package com.jenny.compressedtnt.entities;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.world.entity.*;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.phys.AABB;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class blackHolePrimedTNT extends basePrimedTNT {
|
|
||||||
private static final EntityDataAccessor<Float> DATA_SPEED_ID = SynchedEntityData.defineId(blackHolePrimedTNT.class, EntityDataSerializers.FLOAT);
|
|
||||||
|
|
||||||
public blackHolePrimedTNT(Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse, float speed) {
|
|
||||||
super(entities.TNT_BLACK_HOLE.get(), pLevel, pOwner);
|
|
||||||
this.setRenderID("black_hole");
|
|
||||||
this.setPos(pX, pY, pZ);
|
|
||||||
this.setOwner(pOwner);
|
|
||||||
this.setSpeed(speed);
|
|
||||||
this.setPower(power);
|
|
||||||
this.setFuse(fuse);
|
|
||||||
}
|
|
||||||
|
|
||||||
public blackHolePrimedTNT(EntityType<blackHolePrimedTNT> entityType, Level level) {
|
|
||||||
super(entityType, level, null);
|
|
||||||
this.setRenderID("black_hole");
|
|
||||||
}
|
|
||||||
|
|
||||||
private Vec3 targetVector(Entity target) {
|
|
||||||
double dist = getTargetDist(target);
|
|
||||||
float speed = getSpeed();
|
|
||||||
Vec3 mult = new Vec3(speed / dist, speed / dist, speed / dist);
|
|
||||||
Vec3 ret = this.position().subtract(target.position()).normalize().multiply(mult);
|
|
||||||
if (dist < this.position().subtract(target.position().add(ret)).length()) {
|
|
||||||
// reduce overshoot
|
|
||||||
return Vec3.ZERO;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTargetDist(Entity target) {
|
|
||||||
return target.position().subtract(this.position()).length();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Entity> findTargets() {
|
|
||||||
Vec3 corner1 = this.position().subtract(15, 15, 15);
|
|
||||||
Vec3 corner2 = this.position().add(15, 15, 15);
|
|
||||||
AABB boundingBox = new AABB(corner1, corner2);
|
|
||||||
return this.level().getEntities(this, boundingBox);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
for (Entity e : findTargets()) {
|
|
||||||
e.addDeltaMovement(targetVector(e));
|
|
||||||
}
|
|
||||||
super.tick();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addAdditionalSaveData(CompoundTag pCompound) {
|
|
||||||
pCompound.putFloat("Speed", this.getSpeed());
|
|
||||||
super.addAdditionalSaveData(pCompound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readAdditionalSaveData(CompoundTag pCompound) {
|
|
||||||
this.setSpeed(pCompound.getFloat("Speed"));
|
|
||||||
super.readAdditionalSaveData(pCompound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSpeed(float speed) {
|
|
||||||
this.entityData.set(DATA_SPEED_ID, speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSpeed() {
|
|
||||||
return this.entityData.get(DATA_SPEED_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void defineSynchedData() {
|
|
||||||
this.entityData.define(DATA_SPEED_ID, 4.0f);
|
|
||||||
super.defineSynchedData();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected float getEyeHeight(@NotNull Pose pPose, @NotNull EntityDimensions pSize) {
|
|
||||||
return 0.15F;
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,10 +28,6 @@ public class entities {
|
|||||||
ENTITY_TYPES.register("tnt_cluster", () -> EntityType.Builder.<ClusterPrimedTNT>of(ClusterPrimedTNT::new, MobCategory.MISC)
|
ENTITY_TYPES.register("tnt_cluster", () -> EntityType.Builder.<ClusterPrimedTNT>of(ClusterPrimedTNT::new, MobCategory.MISC)
|
||||||
.sized(0.48F, 0.48F).fireImmune().clientTrackingRange(8).build("tnt_cluster"));
|
.sized(0.48F, 0.48F).fireImmune().clientTrackingRange(8).build("tnt_cluster"));
|
||||||
|
|
||||||
public static final RegistryObject<EntityType<blackHolePrimedTNT>> TNT_BLACK_HOLE =
|
|
||||||
ENTITY_TYPES.register("tnt_chunk", () -> EntityType.Builder.<blackHolePrimedTNT>of(blackHolePrimedTNT::new, MobCategory.MISC)
|
|
||||||
.sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_chunk"));
|
|
||||||
|
|
||||||
public static void register(IEventBus eventBus) {
|
public static void register(IEventBus eventBus) {
|
||||||
ENTITY_TYPES.register(eventBus);
|
ENTITY_TYPES.register(eventBus);
|
||||||
}
|
}
|
||||||
@ -39,7 +35,6 @@ public class entities {
|
|||||||
public static void registerRenderers () {
|
public static void registerRenderers () {
|
||||||
EntityRenderers.register(TNT_STRONGER.get(), BaseTNTRenderer::new);
|
EntityRenderers.register(TNT_STRONGER.get(), BaseTNTRenderer::new);
|
||||||
EntityRenderers.register(TNT_HOMING.get(), BaseTNTRenderer::new);
|
EntityRenderers.register(TNT_HOMING.get(), BaseTNTRenderer::new);
|
||||||
EntityRenderers.register(TNT_BLACK_HOLE.get(), BaseTNTRenderer::new);
|
|
||||||
EntityRenderers.register(TNT_CLUSTER.get(), clusterTNTRenderer::new);
|
EntityRenderers.register(TNT_CLUSTER.get(), clusterTNTRenderer::new);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"variants": {
|
|
||||||
"": {
|
|
||||||
"model": "compressedtnt:block/ttn_black_hole"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "minecraft:crafting_shapeless",
|
|
||||||
"category": "redstone",
|
|
||||||
"ingredients":[
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:end_crystal"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"item": "compressedtnt:tnt_black_hole"
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,10 +3,8 @@
|
|||||||
"category": "redstone",
|
"category": "redstone",
|
||||||
"ingredients":[
|
"ingredients":[
|
||||||
{
|
{
|
||||||
"item": "minecraft:tnt"
|
"item": "minecraft:tnt",
|
||||||
},
|
"count": 2
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
|
@ -3,16 +3,8 @@
|
|||||||
"category": "redstone",
|
"category": "redstone",
|
||||||
"ingredients":[
|
"ingredients":[
|
||||||
{
|
{
|
||||||
"item": "minecraft:tnt"
|
"item": "minecraft:tnt",
|
||||||
},
|
"count": 4
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
"category": "redstone",
|
"category": "redstone",
|
||||||
"ingredients":[
|
"ingredients":[
|
||||||
{
|
{
|
||||||
"item": "compressedtnt:tnt_cluster_2"
|
"item": "compressedtnt:tnt_cluster_2",
|
||||||
},
|
"count": 2
|
||||||
{
|
|
||||||
"item": "compressedtnt:tnt_cluster_2"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
|
@ -3,28 +3,8 @@
|
|||||||
"category": "redstone",
|
"category": "redstone",
|
||||||
"ingredients":[
|
"ingredients":[
|
||||||
{
|
{
|
||||||
"item": "minecraft:tnt"
|
"item": "minecraft:tnt",
|
||||||
},
|
"count": 8
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "minecraft:tnt"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
|
@ -3,16 +3,8 @@
|
|||||||
"category": "redstone",
|
"category": "redstone",
|
||||||
"ingredients":[
|
"ingredients":[
|
||||||
{
|
{
|
||||||
"item": "compressedtnt:tnt_cluster_2"
|
"item": "compressedtnt:tnt_cluster_2",
|
||||||
},
|
"count": 4
|
||||||
{
|
|
||||||
"item": "compressedtnt:tnt_cluster_2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "compressedtnt:tnt_cluster_2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "compressedtnt:tnt_cluster_2"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
"category": "redstone",
|
"category": "redstone",
|
||||||
"ingredients":[
|
"ingredients":[
|
||||||
{
|
{
|
||||||
"item": "compressedtnt:tnt_cluster_4"
|
"item": "compressedtnt:tnt_cluster_4",
|
||||||
},
|
"count": 2
|
||||||
{
|
|
||||||
"item": "compressedtnt:tnt_cluster_4"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"result": {
|
"result": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user