Skip to content

Commit 3dc16a3

Browse files
committed
Fix more comparator/tile entity jank
1 parent ddc4e99 commit 3dc16a3

55 files changed

Lines changed: 1381 additions & 234 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

_VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.0
1+
0.2.1

build_stats.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; Stats tracked as of version 0.0.9
2-
TotalBuilds=1007
3-
TotalRuns=933
4-
SuccessRuns=670
5-
FailedRuns=263
2+
TotalBuilds=1037
3+
TotalRuns=963
4+
SuccessRuns=681
5+
FailedRuns=282
66
TotalReleases=74
77
SuccessReleases=67
88
FailedReleases=7

feature_list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Comparators:
144144
- Enabled rotation on turntables
145145
- Fixed placement from block dispensers
146146
- Fixed MC-8911, MC-10653, MC-12211, MC-63669, and MC-195351
147+
- Properly detect breaking/moving of blocks
147148

148149
Repeaters:
149150
- Renders properly on top of transparent blocks

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ archives_base_name = zero_btw_addon_test
1010

1111
org.gradle.jvmargs=-Xmx4g
1212
org.gradle.daemon=false
13-
mod_version = 0.2.0
13+
mod_version = 0.2.1

src/main/java/zero/test/IBlockEntityPistonMixins.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public interface IBlockEntityPistonMixins {
88
public void setLastTicked(long time);
99
public boolean hasSmallCenterHardPointToFacing(int x, int y, int z, int direction, boolean ignoreTransparency);
1010
public boolean hasCenterHardPointToFacing(int x, int y, int z, int direction, boolean ignoreTransparency);
11+
public TileEntity getStoredTileEntity();
1112
public boolean isRetractingBase();
1213
public boolean hasLargeCenterHardPointToFacing(int x, int y, int z, int direction, boolean ignoreTransparency);
1314
public void getCollisionList(AxisAlignedBB maskBox, List list, Entity entity);

src/main/java/zero/test/PistonResolver.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ public boolean moveBlocks(World world, int x, int y, int z, int direction, boole
490490
blockMeta = block.adjustMetadataForPistonMove(blockMeta);
491491
;
492492
NBTTagCompound tileEntityData = BlockPistonBase.getBlockTileEntityData(world, x, y, z);
493-
// Removing this seems to be safe...
494493
world.removeBlockTileEntity(x, y, z);
495494
packedPos = ((long)(z + Facing.offsetsZForSide[direction])<<12 +26|(long)((x + Facing.offsetsXForSide[direction])&0x3FFFFFF)<<12|((y + Facing.offsetsYForSide[direction])&0xFFF));
496495
int j = i;
@@ -578,12 +577,16 @@ else if (
578577
for (int i = destroy_index_global; --i >= DESTROY_LIST_START_INDEX;) {
579578
// Set x,y,z to position of block in destroy list
580579
packedPos = pushed_blocks[i];
581-
world.notifyBlocksOfNeighborChange(((int)((packedPos)<<26>>(64)-26)),((int)(packedPos)<<(32)-12>>(32)-12),((int)((packedPos)>>(64)-26)), ((data_list[i])&0xFFFF));
580+
//world.notifyBlocksOfNeighborChange(BLOCK_POS_UNPACK_ARGS(packedPos), BLOCK_STATE_EXTRACT_ID(data_list[i]));
581+
blockId = ((data_list[i])&0xFFFF);
582+
((IWorldMixins)world).notifyBlockChangeAndComparators(((int)((packedPos)<<26>>(64)-26)),((int)(packedPos)<<(32)-12>>(32)-12),((int)((packedPos)>>(64)-26)), blockId, blockId);
582583
}
583584
for (int i = push_index_global; --i >= PUSH_LIST_START_INDEX;) {
584585
// Set x,y,z to position of block in push list
585586
packedPos = pushed_blocks[i];
586-
world.notifyBlocksOfNeighborChange(((int)((packedPos)<<26>>(64)-26)),((int)(packedPos)<<(32)-12>>(32)-12),((int)((packedPos)>>(64)-26)), ((data_list[i])&0xFFFF));
587+
//world.notifyBlocksOfNeighborChange(BLOCK_POS_UNPACK_ARGS(packedPos), BLOCK_STATE_EXTRACT_ID(data_list[i]));
588+
blockId = ((data_list[i])&0xFFFF);
589+
((IWorldMixins)world).notifyBlockChangeAndComparators(((int)((packedPos)<<26>>(64)-26)),((int)(packedPos)<<(32)-12>>(32)-12),((int)((packedPos)>>(64)-26)), blockId, blockId);
587590
}
588591
// START SHOVEL CODE
589592
for (int i = shovel_index_global; --i >= SHOVEL_EJECT_LIST_START_INDEX;) {

src/main/java/zero/test/TurntableResolver.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import zero.test.mixin.IPistonBaseAccessMixins;
1212
import zero.test.IWorldMixins;
1313
import zero.test.IBlockEntityPistonMixins;
14+
import zero.test.ZeroUtil;
1415
// Block piston reactions
1516
public class TurntableResolver {
1617
private static final int TURNTABLE_HEIGHT_LIMIT =
@@ -158,11 +159,16 @@ public int turnBlocks(World world, int x, int y, int z, boolean reverse, int cra
158159
for (int i = attachment_index_global; --i >= ATTACHMENT_LIST_START_INDEX;) {
159160
packedPos = pillar_blocks[i];
160161
{(x)=((int)((packedPos)<<26>>(64)-26));(z)=((int)((packedPos)>>(64)-26));(y)=((int)(packedPos)<<(32)-12>>(32)-12);};
161-
if (Block.blocksList[((data_list[i])&0xFFF)].hasTileEntity()) {
162+
blockId = ((data_list[i])&0xFFF);
163+
Block block = Block.blocksList[blockId];
164+
if (block.hasTileEntity()) {
162165
tile_entity_list[tile_entity_index++] = world.getBlockTileEntity(x, y, z);
163166
world.removeBlockTileEntity(x, y, z);
164167
}
165168
world.setBlock(x, y, z, 0, 0, 0x01 | 0x02);
169+
if (block.hasComparatorInputOverride()) {
170+
world.func_96440_m(x, y, z, blockId);
171+
}
166172
}
167173
for (int i = pillar_index_global; --i >= PILLAR_LIST_START_INDEX;) {
168174
packedPos = pillar_blocks[i];
@@ -217,6 +223,9 @@ public int turnBlocks(World world, int x, int y, int z, boolean reverse, int cra
217223
}
218224
}
219225
else {
226+
if (tile_entity != null) {
227+
ZeroUtil.break_tile_entity(world, x, y, z, tile_entity);
228+
}
220229
// This seems like it could be an issue.
221230
// Maybe destroy the block instead?
222231
block.dropBlockAsItem(world, x, y, z, blockId, blockMeta);

src/main/java/zero/test/ZeroTestAddon.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public class ZeroTestAddon extends BTWAddon {
1818
private static ZeroTestAddon instance;
1919
private ZeroTestAddon() {
20-
super("Zero Test Addon", "0.2.0", "ZeroTest");
20+
super("Zero Test Addon", "0.2.1", "ZeroTest");
2121
}
2222
@Override
2323
public void initialize() {
@@ -270,6 +270,16 @@ public void postInitialize() {
270270
'B', new ItemStack(BTWItems.stoneBrick, 1, InventoryUtils.IGNORE_METADATA)
271271
}
272272
);
273+
RecipeManager.addRecipe(
274+
new ItemStack(Block.dropper, 1),
275+
new Object[] {
276+
"###",
277+
"# #",
278+
"#R#",
279+
'#', new ItemStack(BTWItems.stoneBrick, 1, InventoryUtils.IGNORE_METADATA),
280+
'R', BTWItems.redstoneLatch
281+
}
282+
);
273283
}
274284
// Is this important?
275285
// Also looks kinda backwards tbh (I tried fixing it)

src/main/java/zero/test/ZeroUtil.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package zero.test;
22
import net.minecraft.src.*;
3+
import btw.block.tileentity.*;
4+
import btw.item.util.ItemUtils;
5+
import btw.inventory.util.InventoryUtils;
36
import btw.AddonHandler;
7+
import java.util.Random;
48
// Block piston reactions
59
public class ZeroUtil {
610
public static final int[] rail_exit_directions = new int[] {
@@ -78,4 +82,30 @@ public static float angle_rotate_180(float angle) {
7882
}
7983
return angle;
8084
}
85+
public static double triangle_random(Random random, double offset, double range) {
86+
return offset + range * (random.nextDouble() - random.nextDouble());
87+
}
88+
public static void break_tile_entity(World world, int x, int y, int z, TileEntity tileEntity) {
89+
if (tileEntity instanceof IInventory) {
90+
InventoryUtils.ejectInventoryContents(world, x, y, z, (IInventory)tileEntity);
91+
}
92+
else if (tileEntity instanceof TileEntityRecordPlayer) {
93+
ItemStack record;
94+
if ((record = ((TileEntityRecordPlayer)tileEntity).func_96097_a()) != null) {
95+
ItemUtils.ejectStackWithRandomOffset(world, x, y, z, record);
96+
}
97+
}
98+
else if (tileEntity instanceof ArcaneVesselTileEntity) {
99+
((ArcaneVesselTileEntity)tileEntity).ejectContentsOnBlockBreak();
100+
}
101+
else if (tileEntity instanceof BasketTileEntity) {
102+
((BasketTileEntity)tileEntity).ejectContents();
103+
}
104+
else if (tileEntity instanceof PlacedToolTileEntity) {
105+
((PlacedToolTileEntity)tileEntity).ejectContents();
106+
}
107+
else if (tileEntity instanceof CampfireTileEntity) {
108+
((CampfireTileEntity)tileEntity).ejectContents();
109+
}
110+
}
81111
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package zero.test.block;
2+
import net.minecraft.src.*;
3+
// Block piston reactions
4+
public class DropperShim
5+
extends BlockDropper
6+
{
7+
public DropperShim(int blockId) {
8+
super(blockId);
9+
}
10+
}

0 commit comments

Comments
 (0)