1.15: Forge 31.2.20 requirement declared. All: Placer checks for collidable entities (issue #98). Breaker drop trajectory tuned. Pipe valve Redstone connector conditions. All tickable TEs verify their current blockstate to prevent crashes when blocks are forcefully moved (issue #101).

This commit is contained in:
stfwi 2020-06-21 17:01:55 +02:00
parent f46b2b6bc7
commit e8f32e29a1
67 changed files with 219 additions and 125 deletions

View file

@ -70,7 +70,7 @@ init:
@$(GRADLE) eclipse
sanitize:
@echo "[1.14] Running sanatising tasks ..."
@echo "[1.14] Running sanitising tasks ..."
@$(TASK) sanitize
@$(TASK) sync-languages
@$(TASK) version-check

View file

@ -5,4 +5,4 @@ version_minecraft=1.14.4
version_forge_minecraft=1.14.4-28.2.3
version_fml_mappings=20190719-1.14.3
version_jei=1.14.4:6.0.0.10
version_engineersdecor=1.1.0-b2
version_engineersdecor=1.1.0-b3

View file

@ -1,6 +1,7 @@
{
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
"1.14.4": {
"1.1.0-b3": "[F] Block Placer defers placements if collidable entities are in the way (issue #98, thx DrakoAlcarus).\n[M] Block Breaker item drop trajectories have lower speed (fall slightly straighter down).\n[M] Pipe Valves redstone connector also shown if the adjacent block can connect redstone in general.\n[F] Added Block verification during TE ticking in case devices are moved (issue #101, thx D0CTOR-ZED).",
"1.1.0-b2": "[A] Added tooltips for buttons/settings in device GUIs (1.5s display delay).",
"1.1.0-b1": "[F] Fixed Electrical Furnace speed sanitizing bug (issue #97, thx therobotmenace).\n[A] Sheet Metal Slab Slices added (only available if IE is installed).\n[M] Config options extended/updated.\n[M] Dense Grit Sand textures altered to get slightly more visible structure from distance.",
"1.0.20-b7": "[A] Dense Grit Sand added.\n[!] Variant Slab compatibility fix. *This may alter placed slabs of this mod, data fixers don't work yet unfortunately*.",
@ -58,6 +59,6 @@
},
"promos": {
"1.14.4-recommended": "",
"1.14.4-latest": "1.1.0-b2"
"1.14.4-latest": "1.1.0-b3"
}
}

View file

@ -11,6 +11,11 @@ Mod sources for Minecraft version 1.14.4.
## Version history
- v1.1.0-b3 [F] Block Placer defers placements if collidable entities are in the way (issue #98, thx DrakoAlcarus).
[M] Block Breaker item drop trajectories have lower speed (fall slightly straighter down).
[M] Pipe Valves redstone connector also shown if the adjacent block can connect redstone in general.
[F] Added Block verification during TE ticking in case devices are moved (issue #101, thx D0CTOR-ZED).
- v1.1.0-b2 [A] Added tooltips for buttons/settings in device GUIs (1.5s display delay).
- v1.1.0-b1 [F] Fixed Electrical Furnace speed sanitizing bug (issue #97, thx therobotmenace).

View file

@ -195,12 +195,12 @@ public class ModContent
public static final EdGlassBlock PANZERGLASS_BLOCK = (EdGlassBlock)(new EdGlassBlock(
DecorBlock.CFG_TRANSLUCENT,
Block.Properties.create(Material.GLASS, MaterialColor.AIR).hardnessAndResistance(5f, 2000f).sound(SoundType.METAL)
Block.Properties.create(Material.GLASS, MaterialColor.AIR).hardnessAndResistance(0.7f, 2000f).sound(SoundType.METAL)
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "panzerglass_block"));
public static final EdSlabBlock PANZERGLASS_SLAB = (EdSlabBlock)(new EdSlabBlock(
DecorBlock.CFG_TRANSLUCENT,
Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(5f, 2000f).sound(SoundType.METAL)
Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(0.7f, 2000f).sound(SoundType.METAL)
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "panzerglass_slab"));
// -------------------------------------------------------------------------------------------------------------------

View file

@ -13,8 +13,9 @@ import wile.engineersdecor.ModEngineersDecor;
import wile.engineersdecor.libmc.blocks.StandardBlocks;
import wile.engineersdecor.libmc.detail.Auxiliaries;
import wile.engineersdecor.libmc.detail.Overlay;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.GameRules;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
@ -26,6 +27,7 @@ import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ParticleTypes;
@ -272,6 +274,19 @@ public class EdBreaker
return true;
}
private static void spawnBlockAsEntity(World world, BlockPos pos, ItemStack stack) {
if(world.isRemote || stack.isEmpty() || (!world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) || world.restoringBlockSnapshots) return;
ItemEntity e = new ItemEntity(world,
((world.rand.nextFloat()*0.1)+0.5) + pos.getX(),
((world.rand.nextFloat()*0.1)+0.5) + pos.getY(),
((world.rand.nextFloat()*0.1)+0.5) + pos.getZ(),
stack
);
e.setDefaultPickupDelay();
e.setMotion((world.rand.nextFloat()*0.1-0.05), (world.rand.nextFloat()*0.1-0.03), (world.rand.nextFloat()*0.1-0.05));
world.addEntity(e);
}
private boolean breakBlock(BlockState state, BlockPos pos, World world)
{
if(world.isRemote || (!(world instanceof ServerWorld)) || world.restoringBlockSnapshots) return false; // retry next cycle
@ -279,7 +294,7 @@ public class EdBreaker
final Block block = state.getBlock();
drops = Block.getDrops(state, (ServerWorld)world, pos, world.getTileEntity(pos));
world.removeBlock(pos, false);
for(ItemStack drop:drops) Block.spawnAsEntity(world, pos, drop);
for(ItemStack drop:drops) spawnBlockAsEntity(world, pos, drop);
SoundType stype = state.getBlock().getSoundType(state, world, pos, null);
if(stype != null) world.playSound(null, pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch());
return true;
@ -290,15 +305,16 @@ public class EdBreaker
public void tick()
{
if(--tick_timer_ > 0) return;
final BlockState device_state = world.getBlockState(pos);
if(!(device_state.getBlock() instanceof BreakerBlock)) return;
if(world.isRemote) {
BlockState state = world.getBlockState(pos);
if(!state.get(BreakerBlock.ACTIVE)) {
if(!device_state.get(BreakerBlock.ACTIVE)) {
tick_timer_ = TICK_INTERVAL;
} else {
tick_timer_ = 1;
// not sure if is so cool to do this each tick ... may be simplified/removed again.
SoundEvent sound = SoundEvents.BLOCK_WOOD_HIT;
BlockState target_state = world.getBlockState(pos.offset(state.get(BreakerBlock.HORIZONTAL_FACING)));
BlockState target_state = world.getBlockState(pos.offset(device_state.get(BreakerBlock.HORIZONTAL_FACING)));
SoundType stype = target_state.getBlock().getSoundType(target_state);
if((stype == SoundType.CLOTH) || (stype == SoundType.PLANT) || (stype == SoundType.SNOW)) {
sound = SoundEvents.BLOCK_WOOL_HIT;
@ -309,7 +325,6 @@ public class EdBreaker
}
} else {
tick_timer_ = TICK_INTERVAL;
final BlockState device_state = world.getBlockState(pos);
final BlockPos target_pos = pos.offset(device_state.get(BreakerBlock.HORIZONTAL_FACING));
final BlockState target_state = world.getBlockState(target_pos);
if((world.isBlockPowered(pos)) || (!isBreakable(target_state, target_pos, world))) {

View file

@ -553,6 +553,7 @@ public class EdDropper
if((drop_timer_ > 0) && ((--drop_timer_) == 0)) markDirty();
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
if(!(world.getBlockState(pos).getBlock() instanceof DropperBlock)) return;
final boolean continuous_mode = (drop_logic_ & DROPLOGIC_CONTINUOUS)!=0;
boolean dirty = block_power_updated_;
boolean redstone_trigger = (block_power_signal_ && ((block_power_updated_) || (continuous_mode)));

View file

@ -475,6 +475,7 @@ public class EdElectricalFurnace
{
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
if(!(world.getBlockState(pos).getBlock() instanceof ElectricalFurnaceBlock)) return;
final boolean was_burning = burning();
if(was_burning) burntime_left_ -= TICK_INTERVAL;
if(burntime_left_ < 0) burntime_left_ = 0;

View file

@ -212,10 +212,10 @@ public class EdFluidAccumulator
{
if((world.isRemote) || (--tick_timer_ > 0)) return;
tick_timer_ = tick_idle_interval;
BlockState state = world.getBlockState(pos);
if(!(state.getBlock() instanceof FluidAccumulatorBlock)) return;
if(!initialized_) {
initialized_ = true;
BlockState state = world.getBlockState(pos);
if((state==null) || (!(state.getBlock() instanceof FluidAccumulatorBlock))) return;
block_facing_ = state.get(FluidAccumulatorBlock.FACING);
}
int n_requested = last_drain_request_amount_;

View file

@ -406,6 +406,8 @@ public class EdFluidFunnel
if((world.isRemote) || (--tick_timer_ > 0)) return;
tick_timer_ = TICK_INTERVAL;
collection_timer_ += TICK_INTERVAL;
final BlockState funnel_state = world.getBlockState(pos);
if(!(funnel_state.getBlock() instanceof FluidFunnelBlock)) return;
boolean dirty = false;
// Collection
if((collection_timer_ >= COLLECTION_INTERVAL) && ((tank_==null) || (tank_.getAmount() <= (TANK_CAPACITY-1000)))) {
@ -427,7 +429,6 @@ public class EdFluidFunnel
}
// Block state
int fill_level = (tank_==null) ? 0 : (MathHelper.clamp(tank_.getAmount()/1000,0, FluidFunnelBlock.FILL_LEVEL_MAX));
final BlockState funnel_state = world.getBlockState(pos);
if(funnel_state.get(FluidFunnelBlock.FILL_LEVEL) != fill_level) world.setBlockState(pos, funnel_state.with(FluidFunnelBlock.FILL_LEVEL, fill_level), 2|16);
if(dirty) markDirty();
}

View file

@ -546,6 +546,8 @@ public class EdFurnace
{
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
final BlockState state = world.getBlockState(pos);
if(!(state.getBlock() instanceof FurnaceBlock)) return;
final boolean was_burning = burning();
if(was_burning) burntime_left_ -= TICK_INTERVAL;
if(burntime_left_ < 0) burntime_left_ = 0;
@ -602,10 +604,7 @@ public class EdFurnace
}
if(was_burning != burning()) {
dirty = true;
final BlockState state = world.getBlockState(pos);
if(state.getBlock() instanceof FurnaceBlock) {
world.setBlockState(pos, state.with(FurnaceBlock.LIT, burning()));
}
world.setBlockState(pos, state.with(FurnaceBlock.LIT, burning()));
}
if(dirty) {
markDirty();

View file

@ -619,13 +619,13 @@ public class EdHopper
if((delay_timer_ > 0) && ((--delay_timer_) == 0)) markDirty();
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
final BlockState state = world.getBlockState(pos);
if(!(state.getBlock() instanceof HopperBlock)) { block_power_signal_= false; return; }
// Cycle init
boolean dirty = block_power_updated_;
final boolean rssignal = ((logic_ & LOGIC_INVERTED)!=0)==(!block_power_signal_);
final boolean pulse_mode = ((logic_ & LOGIC_CONTINUOUS)==0);
boolean trigger = (rssignal && ((block_power_updated_) || (!pulse_mode)));
final BlockState state = world.getBlockState(pos);
if(state == null) { block_power_signal_= false; return; }
final Direction hopper_facing = state.get(HopperBlock.FACING);
// Trigger edge detection for next cycle
{

View file

@ -529,6 +529,7 @@ public class EdMilker
tick_timer_ = TICK_INTERVAL;
boolean dirty = false;
final BlockState block_state = world.getBlockState(pos);
if(!(block_state.getBlock() instanceof MilkerBlock)) return;
if(!world.isBlockPowered(pos) || (state_ != MilkingState.IDLE)) {
if(energy_consumption > 0) {
if(energy_stored_ <= 0) return;

View file

@ -566,6 +566,8 @@ public class EdMineralSmelter
if(world.isRemote) return;
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
BlockState state = world.getBlockState(pos);
if(!(state.getBlock() instanceof MineralSmelterBlock)) return;
boolean dirty = false;
final int last_phase = phase();
final ItemStack istack = stacks_.get(0);
@ -655,8 +657,7 @@ public class EdMineralSmelter
}
}
// Block state
BlockState state = world.getBlockState(pos);
if((state.getBlock() instanceof MineralSmelterBlock) && (force_block_update_ || (state.get(MineralSmelterBlock.PHASE) != new_phase))) {
if(force_block_update_ || (state.get(MineralSmelterBlock.PHASE) != new_phase)) {
state = state.with(MineralSmelterBlock.PHASE, new_phase);
world.setBlockState(pos, state,3|16);
world.notifyNeighborsOfStateChange(getPos(), state.getBlock());

View file

@ -77,14 +77,13 @@ public class EdPipeValve
{
if((valve_config & (CFG_REDSTONE_CONTROLLED_VALVE))==0) return state;
Direction.Axis bfa = state.get(FACING).getAxis();
int bfi = state.get(FACING).getIndex();
for(Direction f:Direction.values()) {
boolean cn = (f.getAxis() != bfa);
if(cn) {
BlockPos nbp = pos.offset(f);
if((fromPos != null) && (!nbp.equals(fromPos))) continue; // do not change connectors except form the frompos.
BlockState nbs = world.getBlockState(nbp);
if(!nbs.canProvidePower()) cn = false; // @todo check if there is a direction selective canProvidePower().
if((!nbs.canProvidePower()) && (!nbs.canConnectRedstone(world, nbp, f.getOpposite()))) cn = false;
}
switch(f) {
case NORTH: state = state.with(RS_CN_N, cn); break;

View file

@ -21,6 +21,7 @@ import net.minecraft.world.server.ServerWorld;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.LivingEntity;
@ -490,7 +491,10 @@ public class EdPlacer
placement_pos = placement_pos.up();
}
}
} else if(!world.getBlockState(placement_pos).getMaterial().isReplaceable()) {
} else if(
(!world.getBlockState(placement_pos).getMaterial().isReplaceable()) ||
(!world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(placement_pos), Entity::canBeCollidedWith).isEmpty())
) {
block = Blocks.AIR;
no_space = true;
}
@ -559,12 +563,12 @@ public class EdPlacer
if(world.isRemote) return;
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
final BlockState state = world.getBlockState(pos);
if(!(state.getBlock() instanceof PlacerBlock)) { block_power_signal_= false; return; }
// Cycle init
boolean dirty = block_power_updated_;
boolean rssignal = ((logic_ & LOGIC_INVERTED)!=0)==(!block_power_signal_);
boolean trigger = (rssignal && ((block_power_updated_) || ((logic_ & LOGIC_CONTINUOUS)!=0)));
final BlockState state = world.getBlockState(pos);
if(state == null) { block_power_signal_= false; return; }
final Direction placer_facing = state.get(PlacerBlock.FACING);
// Trigger edge detection for next cycle
{

View file

@ -193,6 +193,8 @@ public class EdSolarPanel
{
if((world.isRemote) || (--tick_timer_ > 0)) return;
tick_timer_ = TICK_INTERVAL;
final BlockState state = world.getBlockState(pos);
if(!(state.getBlock() instanceof SolarPanelBlock)) return;
current_feedin_ = 0;
if(output_enabled_) {
for(int i=0; (i<transfer_directions_.length) && (accumulated_power_>0); ++i) {
@ -211,13 +213,11 @@ public class EdSolarPanel
if(!world.canBlockSeeSky(pos)) {
tick_timer_ = TICK_INTERVAL * 5;
current_production_ = 0;
BlockState state = world.getBlockState(pos);
if(state.get((SolarPanelBlock.EXPOSITION))!=2) world.setBlockState(pos, state.with(SolarPanelBlock.EXPOSITION, 2));
return;
}
if(--recalc_timer_ > 0) return;
recalc_timer_ = ACCUMULATION_INTERVAL + ((int)(Math.random()+.5));
BlockState state = world.getBlockState(pos);
int theta = ((((int)(world.getCelestialAngleRadians(1f) * (180.0/Math.PI)))+90) % 360);
int e = 2;
if(theta > 340) e = 2;

View file

@ -214,8 +214,10 @@ public class EdTreeCutter
public void tick()
{
if(--tick_timer_ > 0) return;
final BlockState device_state = world.getBlockState(pos);
if(!(device_state.getBlock() instanceof TreeCutterBlock)) { tick_timer_ = TICK_INTERVAL; return; }
if(world.isRemote) {
if(!world.getBlockState(pos).get(TreeCutterBlock.ACTIVE)) {
if(!device_state.get(TreeCutterBlock.ACTIVE)) {
tick_timer_ = TICK_INTERVAL;
} else {
tick_timer_ = 1;
@ -223,7 +225,6 @@ public class EdTreeCutter
}
} else {
tick_timer_ = TICK_INTERVAL;
final BlockState device_state = world.getBlockState(pos);
final BlockPos tree_pos = pos.offset(device_state.get(TreeCutterBlock.HORIZONTAL_FACING));
final BlockState tree_state = world.getBlockState(tree_pos);
if(!TreeCutting.canChop(tree_state) || (world.isBlockPowered(pos))) {

View file

@ -509,6 +509,8 @@ public class EdWasteIncinerator
if(--tick_timer_ > 0) return;
tick_timer_ = TICK_INTERVAL;
if(world.isRemote) return;
final BlockState state = world.getBlockState(pos);
if(!(state.getBlock() instanceof WasteIncineratorBlock)) return;
boolean dirty = false;
ItemStack processing_stack = stacks_.get(BURN_SLOT_NO);
final boolean was_processing = !processing_stack.isEmpty();
@ -542,10 +544,7 @@ public class EdWasteIncinerator
}
if((was_processing != is_processing) || (new_stack_processing)) {
if(new_stack_processing) world.playSound(null, pos, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.BLOCKS, 0.05f, 2.4f);
final BlockState state = world.getBlockState(pos);
if(state.getBlock() instanceof WasteIncineratorBlock) {
world.setBlockState(pos, state.with(WasteIncineratorBlock.LIT, is_processing), 2|16);
}
world.setBlockState(pos, state.with(WasteIncineratorBlock.LIT, is_processing), 2|16);
}
if(dirty) markDirty();
}