Skip to content

Commit cda151d

Browse files
authored
Merge pull request #15 from TBoshoven/1.14-magic-mirror-tile-entity-fix
Fix behavior around tile entity deletion
2 parents bfe091a + 7661bb5 commit cda151d

File tree

5 files changed

+17
-37
lines changed

5 files changed

+17
-37
lines changed

MagicMirror/src/main/java/com/tomboshoven/minecraft/magicmirror/blocks/MagicMirrorBlock.java

+7-15
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,6 @@ public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Null
117117
}
118118
}
119119

120-
@Override
121-
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
122-
super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving);
123-
124-
// Break the mirror if the other part is broken.
125-
if (state.get(COMPLETE)) {
126-
if (
127-
state.get(PART) == EnumPartType.TOP && worldIn.getBlockState(pos.down()).getBlock() != this ||
128-
state.get(PART) == EnumPartType.BOTTOM && worldIn.getBlockState(pos.up()).getBlock() != this
129-
) {
130-
worldIn.setBlockState(pos, state.with(COMPLETE, false));
131-
}
132-
}
133-
}
134-
135120
@Override
136121
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
137122
builder.add(HORIZONTAL_FACING, COMPLETE, PART);
@@ -222,6 +207,13 @@ public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState
222207
if (tileEntity instanceof MagicMirrorBaseTileEntity) {
223208
((MagicMirrorBaseTileEntity) tileEntity).removeModifiers(worldIn, pos);
224209
}
210+
211+
// Change the other part to incomplete
212+
BlockPos otherPos = state.get(PART) == EnumPartType.TOP ? pos.down() : pos.up();
213+
BlockState otherState = worldIn.getBlockState(otherPos);
214+
if (otherState.getBlock() == this) {
215+
worldIn.setBlockState(otherPos, otherState.with(COMPLETE, false));
216+
}
225217
}
226218
super.onReplaced(state, worldIn, pos, newState, isMoving);
227219
}

MagicMirror/src/main/java/com/tomboshoven/minecraft/magicmirror/blocks/tileentities/MagicMirrorBaseTileEntity.java

-7
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,4 @@ public Direction getFacing() {
113113
public EnumPartType getPart() {
114114
return getBlockState().get(MagicMirrorBlock.PART);
115115
}
116-
117-
/**
118-
* @return Whether the mirror is completely constructed.
119-
*/
120-
public boolean isComplete() {
121-
return getBlockState().get(MagicMirrorBlock.COMPLETE);
122-
}
123116
}

MagicMirror/src/main/java/com/tomboshoven/minecraft/magicmirror/blocks/tileentities/MagicMirrorPartTileEntity.java

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public MagicMirrorPartTileEntity() {
2424
@Nullable
2525
@Override
2626
protected MagicMirrorCoreTileEntity getCore() {
27-
if (!isComplete()) {
28-
return null;
29-
}
3027
if (core == null) {
3128
World world = getWorld();
3229
if (world != null) {

MagicMirror/src/main/java/com/tomboshoven/minecraft/magicmirror/renderers/TileEntityMagicMirrorRenderer.java

+9-11
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ class TileEntityMagicMirrorRenderer extends TileEntityRenderer<MagicMirrorBaseTi
3838
public void render(MagicMirrorBaseTileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {
3939
super.render(te, x, y, z, partialTicks, destroyStage);
4040

41-
if (te.isComplete()) {
42-
Reflection reflection = te.getReflection();
41+
Reflection reflection = te.getReflection();
4342

44-
if (reflection != null) {
45-
Entity reflected = reflection.getReflectedEntity();
46-
if (reflected != null) {
47-
EnumPartType part = te.getPart();
48-
Direction facing = te.getFacing();
43+
if (reflection != null) {
44+
Entity reflected = reflection.getReflectedEntity();
45+
if (reflected != null) {
46+
EnumPartType part = te.getPart();
47+
Direction facing = te.getFacing();
4948

50-
Vec3d reflectedPos = reflected.getPositionVector();
51-
double distanceSq = te.getPos().distanceSq(reflectedPos.x, reflectedPos.y, reflectedPos.z, true);
49+
Vec3d reflectedPos = reflected.getPositionVector();
50+
double distanceSq = te.getPos().distanceSq(reflectedPos.x, reflectedPos.y, reflectedPos.z, true);
5251

53-
renderReflection(reflection, x, y, z, partialTicks, part, facing, distanceSq);
54-
}
52+
renderReflection(reflection, x, y, z, partialTicks, part, facing, distanceSq);
5553
}
5654
}
5755
}

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ subprojects {
4949
}
5050

5151
dependencies {
52-
minecraft "net.minecraftforge:forge:1.14.4-28.2.3"
52+
minecraft "net.minecraftforge:forge:1.14.4-28.2.16"
5353

5454
implementation 'com.google.code.findbugs:jsr305:3.0.2'
5555
}

0 commit comments

Comments
 (0)