1.20.1 Port!
This commit is contained in:
parent
8c059a5d2b
commit
b69eda4f90
13 changed files with 143 additions and 188 deletions
|
|
@ -6,8 +6,9 @@ import com.oitsjustjose.charged_explosives.common.CommonProxy;
|
|||
import com.oitsjustjose.charged_explosives.common.TickScheduler;
|
||||
import com.oitsjustjose.charged_explosives.common.config.CommonConfig;
|
||||
import com.oitsjustjose.charged_explosives.common.registry.Registry;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
|
|
@ -56,7 +57,9 @@ public class ChargedExplosives {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSlashReload(AddReloadListenerEvent evt) {
|
||||
public void buildContents(BuildCreativeModeTabContentsEvent event) {
|
||||
if (event.getTabKey() == CreativeModeTabs.REDSTONE_BLOCKS) {
|
||||
event.accept(REGISTRY.CeItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.oitsjustjose.charged_explosives.ChargedExplosives;
|
||||
import com.oitsjustjose.charged_explosives.common.Util;
|
||||
import com.oitsjustjose.charged_explosives.common.config.CommonConfig;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
|
|
@ -13,11 +14,9 @@ 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 {
|
||||
|
||||
|
|
@ -73,58 +72,70 @@ public class ExplosionConfigScreen extends Screen {
|
|||
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.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 40, DECR_W, 20, DECR, onPress -> {
|
||||
var widthDecrButton = new Button.Builder(DECR, onPress -> {
|
||||
if (this.explosionWidth > 1) {
|
||||
this.explosionWidth--;
|
||||
this.dirty = true;
|
||||
this.widthBox.setValue("" + this.explosionWidth);
|
||||
this.widthBox.setValue(String.valueOf(this.explosionWidth));
|
||||
}
|
||||
}));
|
||||
this.widthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 40, EDIT_BOX_WIDTH, 20, Component.literal("")));
|
||||
this.widthBox.setValue("" + this.explosionWidth);
|
||||
this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 40, INCR_W, 20, INCR, onPress -> {
|
||||
}).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 40).size(DECR_W, 20).build();
|
||||
|
||||
var widthIncrButton = new Button.Builder(INCR, onPress -> {
|
||||
if (this.explosionWidth < CommonConfig.MAX_EXPLOSION_WIDTH.get()) {
|
||||
this.explosionWidth++;
|
||||
this.dirty = true;
|
||||
this.widthBox.setValue("" + this.explosionWidth);
|
||||
this.widthBox.setValue(String.valueOf(this.explosionWidth));
|
||||
}
|
||||
}));
|
||||
}).pos(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 40).size(INCR_W, 20).build();
|
||||
|
||||
this.addRenderableWidget(widthDecrButton);
|
||||
this.widthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 40, EDIT_BOX_WIDTH, 20, Component.literal("")));
|
||||
this.widthBox.setValue(String.valueOf(this.explosionWidth));
|
||||
this.addRenderableWidget(widthIncrButton);
|
||||
|
||||
/* Depth Adj */
|
||||
this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 85, DECR_W, 20, DECR, onPress -> {
|
||||
var depthDecrButton = new Button.Builder(DECR, onPress -> {
|
||||
if (this.explosionDepth > 1) {
|
||||
this.explosionDepth--;
|
||||
this.dirty = true;
|
||||
this.depthBox.setValue("" + this.explosionDepth);
|
||||
this.depthBox.setValue(String.valueOf(this.explosionDepth));
|
||||
}
|
||||
}));
|
||||
this.depthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 85, EDIT_BOX_WIDTH, 20, Component.literal("")));
|
||||
this.depthBox.setValue("" + this.explosionDepth);
|
||||
this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 85, INCR_W, 20, INCR, onPress -> {
|
||||
}).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 85).size(DECR_W, 20).build();
|
||||
|
||||
var depthIncrButton = new Button.Builder(INCR, onPress -> {
|
||||
if (this.explosionDepth < CommonConfig.MAX_EXPLOSION_DEPTH.get()) {
|
||||
this.explosionDepth++;
|
||||
this.dirty = true;
|
||||
this.depthBox.setValue("" + this.explosionDepth);
|
||||
this.depthBox.setValue(String.valueOf(this.explosionDepth));
|
||||
}
|
||||
}));
|
||||
}).pos(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 85).size(INCR_W, 20).build();
|
||||
|
||||
this.addRenderableWidget(depthDecrButton);
|
||||
this.depthBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 85, EDIT_BOX_WIDTH, 20, Component.literal("")));
|
||||
this.depthBox.setValue(String.valueOf(this.explosionDepth));
|
||||
this.addRenderableWidget(depthIncrButton);
|
||||
|
||||
/* Height Adj */
|
||||
this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 130, DECR_W, 20, DECR, onPress -> {
|
||||
var heightDecrButton = new Button.Builder(DECR, onPress -> {
|
||||
if (this.explosionHeight > 1) {
|
||||
this.explosionHeight--;
|
||||
this.dirty = true;
|
||||
this.heightBox.setValue("" + this.explosionHeight);
|
||||
this.heightBox.setValue(String.valueOf(this.explosionHeight));
|
||||
}
|
||||
}));
|
||||
this.heightBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 130, EDIT_BOX_WIDTH, 20, Component.literal("")));
|
||||
this.heightBox.setValue("" + this.explosionHeight);
|
||||
this.addRenderableWidget(new Button(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 130, INCR_W, 20, INCR, onPress -> {
|
||||
}).pos(BG_X + ((rowWidth / 2) - 1) + FW_MOD, BG_Y + 130).size(DECR_W, 20).build();
|
||||
|
||||
var heightIncrButton = new Button.Builder(INCR, onPress -> {
|
||||
if (this.explosionHeight < CommonConfig.MAX_EXPLOSION_HEIGHT.get()) {
|
||||
this.explosionHeight++;
|
||||
this.dirty = true;
|
||||
this.heightBox.setValue("" + this.explosionHeight);
|
||||
this.heightBox.setValue(String.valueOf(this.explosionHeight));
|
||||
}
|
||||
}));
|
||||
}).pos(BG_X + ((rowWidth / 2) - 1) + LW_MOD, BG_Y + 130).size(INCR_W, 20).build();
|
||||
|
||||
this.addRenderableWidget(heightDecrButton);
|
||||
this.heightBox = this.addRenderableWidget(new EditBox(this.font, BG_X + ((rowWidth / 2) - 1) + EB_MOD, BG_Y + 130, EDIT_BOX_WIDTH, 20, Component.literal("")));
|
||||
this.heightBox.setValue(String.valueOf(this.explosionHeight));
|
||||
this.addRenderableWidget(heightIncrButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -194,12 +205,7 @@ public class ExplosionConfigScreen extends Screen {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCloseOnEsc() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(@NotNull PoseStack stack, int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(@NotNull GuiGraphics 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;
|
||||
|
||||
|
|
@ -207,17 +213,16 @@ public class ExplosionConfigScreen extends Screen {
|
|||
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);
|
||||
|
||||
stack.blit(BACKGROUND_TEXTURE, (this.width - TEXTURE_WIDTH) / 2, (this.height - TEXTURE_HEIGHT) / 2, 0, 0, TEXTURE_WIDTH, TEXTURE_WIDTH);
|
||||
/* GUI Title */
|
||||
stack.drawString(this.font, this.title, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.title) / 2)), BG_Y + PADDING, 4210752, false );
|
||||
/* 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);
|
||||
stack.drawString(this.font, this.widthTitle, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2)), BG_Y + 20 + this.font.lineHeight, 7089453, false);
|
||||
/* 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);
|
||||
stack.drawString(this.font, this.depthTitle, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2)), BG_Y + 65 + this.font.lineHeight, 7089453, false);
|
||||
/* 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);
|
||||
stack.drawString(this.font, this.heightTitle, (int)(BG_X + (float) (TEXTURE_WIDTH / 2) - (float) (this.font.width(this.widthTitle) / 2)), BG_Y + 110 + this.font.lineHeight, 7089453, false);
|
||||
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
|
@ -226,9 +231,4 @@ public class ExplosionConfigScreen extends Screen {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.google.common.collect.Sets;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.oitsjustjose.charged_explosives.client.config.ClientConfig;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
|
@ -13,6 +12,7 @@ import net.minecraft.util.Tuple;
|
|||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ 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);
|
||||
return new TranslatableContents(transKey, null, new Object[]{}).resolve(null, null, 0);
|
||||
} catch (CommandSyntaxException e) {
|
||||
MutableComponent m = MutableComponent.create(ComponentContents.EMPTY);
|
||||
m.append("Failed to resolve key ");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import net.minecraft.sounds.SoundEvents;
|
|||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
|
@ -23,14 +22,12 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
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.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.entity.EntityTypeTest;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
|
@ -57,7 +54,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
public static final BooleanProperty ACTIVATED = BooleanProperty.create("activated");
|
||||
|
||||
public ChargedExplosiveBlock() {
|
||||
super(BlockBehaviour.Properties.of(Material.EXPLOSIVE, MaterialColor.COLOR_GREEN).dynamicShape().noOcclusion().isValidSpawn((w, x, y, z) -> false).isRedstoneConductor((x, y, z) -> false).isSuffocating((x, y, z) -> false).isViewBlocking((x, y, z) -> false));
|
||||
super(Properties.of().mapColor(MapColor.COLOR_GREEN).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).setValue(ACTIVATED, false));
|
||||
}
|
||||
|
||||
|
|
@ -123,13 +120,13 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
return;
|
||||
}
|
||||
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) {
|
||||
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners());
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) {
|
||||
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners());
|
||||
ItemStack stack = new ItemStack(ChargedExplosives.getInstance().REGISTRY.CeItem.get());
|
||||
cebe.saveToItem(stack);
|
||||
ItemEntity ent = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack);
|
||||
ent.setDefaultPickUpDelay();
|
||||
level.addFreshEntity(ent);
|
||||
ent.saveToItem(stack);
|
||||
ItemEntity itemEntity = new ItemEntity(level, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, stack);
|
||||
itemEntity.setDefaultPickUpDelay();
|
||||
level.addFreshEntity(itemEntity);
|
||||
}
|
||||
|
||||
level.removeBlockEntity(pos);
|
||||
|
|
@ -155,7 +152,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
@Override
|
||||
public void neighborChanged(@NotNull BlockState state, Level level, @NotNull BlockPos pos, @NotNull Block block, @NotNull BlockPos fromPos, boolean isMoving) {
|
||||
if (level.hasNeighborSignal(pos)) {
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) {
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) {
|
||||
if (!state.getValue(ACTIVATED)) {
|
||||
this.explode(level, pos);
|
||||
}
|
||||
|
|
@ -164,7 +161,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
}
|
||||
|
||||
private void explode(Level level, BlockPos pos) {
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) {
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) {
|
||||
BlockState state = level.getBlockState(pos);
|
||||
if (state.getValue(ACTIVATED)) {
|
||||
return;
|
||||
|
|
@ -173,9 +170,9 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
}
|
||||
|
||||
|
||||
cebe.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> this.explodeTask(level, pos), CommonConfig.EXPLOSION_COUNTDOWN_TIME.get())));
|
||||
ent.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> this.explodeTask(level, pos), CommonConfig.EXPLOSION_COUNTDOWN_TIME.get())));
|
||||
for (int i = 0; i < CommonConfig.NUM_BEEPS.get(); i++) {
|
||||
cebe.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> {
|
||||
ent.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> {
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) { // check that it's still there
|
||||
level.playSound(null, pos, ChargedExplosives.getInstance().REGISTRY.BeepSound.get(), SoundSource.BLOCKS, 0.75F, 1.0F);
|
||||
}
|
||||
|
|
@ -187,14 +184,14 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
|
||||
|
||||
private void explodeTask(Level level, BlockPos pos) {
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity cebe) {
|
||||
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity ent) {
|
||||
|
||||
level.playSound(null, pos, SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(cebe.getCorners());
|
||||
ChargedExplosives.getInstance().PROXY.endPreviewExplosion(ent.getCorners());
|
||||
level.removeBlockEntity(pos);
|
||||
level.removeBlock(pos, false);
|
||||
|
||||
cebe.getExplosions().forEach(p -> {
|
||||
ent.getExplosions().forEach(p -> {
|
||||
BlockState state = level.getBlockState(p);
|
||||
if (!state.hasBlockEntity()) {
|
||||
/* indestructible blocks will return -1.0F */
|
||||
|
|
@ -208,7 +205,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
}
|
||||
});
|
||||
|
||||
AABB aabb = new AABB(cebe.getCorners().getA(), cebe.getCorners().getB()).inflate(CommonConfig.CONCUSSIVE_DAMAGE_PADDING.get());
|
||||
AABB aabb = new AABB(ent.getCorners().getA(), ent.getCorners().getB()).inflate(CommonConfig.CONCUSSIVE_DAMAGE_PADDING.get());
|
||||
for (int x = (int) aabb.minX; x < (int) aabb.maxX; x++) {
|
||||
for (int y = (int) aabb.minY; y < (int) aabb.maxY; y++) {
|
||||
for (int z = (int) aabb.minZ; z < (int) aabb.maxZ; z++) {
|
||||
|
|
@ -219,9 +216,9 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
|
|||
}
|
||||
}
|
||||
|
||||
float dmgAmt = cebe.calculateConcussiveDamage();
|
||||
float dmgAmt = ent.calculateConcussiveDamage();
|
||||
List<LivingEntity> entities = level.getEntities(EntityTypeTest.forClass(LivingEntity.class), aabb, Objects::nonNull);
|
||||
entities.forEach(x -> x.hurt(DamageSource.GENERIC, dmgAmt));
|
||||
entities.forEach(x -> x.hurt(level.damageSources().generic(), dmgAmt));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,7 @@ import net.minecraft.world.InteractionHand;
|
|||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
|
@ -30,7 +26,7 @@ import java.util.Objects;
|
|||
|
||||
public class ChargedExplosiveItem extends BlockItem {
|
||||
public ChargedExplosiveItem(Block block) {
|
||||
super(block, new Item.Properties().tab(CreativeModeTab.TAB_REDSTONE));
|
||||
super(block, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -100,11 +96,11 @@ public class ChargedExplosiveItem extends BlockItem {
|
|||
int d = tag.getInt("explosionDepth");
|
||||
int h = tag.getInt("explosionHeight");
|
||||
try {
|
||||
TranslatableContents wc = new TranslatableContents(ChargedExplosives.MODID + ".width_tooltip", w);
|
||||
TranslatableContents wc = new TranslatableContents(ChargedExplosives.MODID + ".width_tooltip", null, new Object[]{w});
|
||||
components.add(wc.resolve(null, null, 0));
|
||||
TranslatableContents dc = new TranslatableContents(ChargedExplosives.MODID + ".depth_tooltip", d);
|
||||
TranslatableContents dc = new TranslatableContents(ChargedExplosives.MODID + ".depth_tooltip", null, new Object[]{d});
|
||||
components.add(dc.resolve(null, null, 0));
|
||||
TranslatableContents hc = new TranslatableContents(ChargedExplosives.MODID + ".height_tooltip", h);
|
||||
TranslatableContents hc = new TranslatableContents(ChargedExplosives.MODID + ".height_tooltip", null, new Object[]{h});
|
||||
components.add(hc.resolve(null, null, 0));
|
||||
} catch (CommandSyntaxException ignored) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ public class Registry {
|
|||
public final RegistryObject<Block> CeBlock = BlockRegistry.register("charged_explosive", ChargedExplosiveBlock::new);
|
||||
public final RegistryObject<Item> CeItem = ItemRegistry.register("charged_explosive", () -> new ChargedExplosiveItem(CeBlock.get()));
|
||||
public final RegistryObject<BlockEntityType<ChargedExplosiveBlockEntity>> CeBlockEntityType = BlockEntityTypeRegistry.register("charged_explosive", () -> BlockEntityType.Builder.of(ChargedExplosiveBlockEntity::new, Blocks.AIR).build(null));
|
||||
public final RegistryObject<SoundEvent> BeepSound = SoundEventRegistry.register("beep", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "beep")));
|
||||
public final RegistryObject<SoundEvent> FailureSound = SoundEventRegistry.register("fail", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "fail")));
|
||||
public final RegistryObject<SoundEvent> BeepSound = SoundEventRegistry.register("beep", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "beep")));
|
||||
public final RegistryObject<SoundEvent> FailureSound = SoundEventRegistry.register("fail", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ChargedExplosives.MODID, "fail")));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue