Skip to content

Commit ddc4e99

Browse files
committed
Finally added a bunch of cool things
1 parent a4fbcc4 commit ddc4e99

63 files changed

Lines changed: 2456 additions & 397 deletions

File tree

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.1.13
1+
0.2.0

build_stats.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; Stats tracked as of version 0.0.9
2-
TotalBuilds=892
3-
TotalRuns=826
4-
SuccessRuns=602
5-
FailedRuns=224
6-
TotalReleases=66
7-
SuccessReleases=60
8-
FailedReleases=6
2+
TotalBuilds=1007
3+
TotalRuns=933
4+
SuccessRuns=670
5+
FailedRuns=263
6+
TotalReleases=74
7+
SuccessReleases=67
8+
FailedReleases=7

feature_list.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ Block Dispensers:
8686
- No longer receive redstone power through their front face (maintains previous behaviors with power rule changes)
8787
- Prioritize the entity closest to the center of the block in front of them
8888

89+
Detector Blocks:
90+
- No longer send block updates 2 blocks aways
91+
8992
Platforms:
9093
- Connect to other platforms when moved by pistons
9194
- Fixed broken code that prevented lifting redstone/rails
@@ -168,7 +171,6 @@ Dead Coral Fan:
168171
///
169172
Planned Features
170173
///
171-
- Giving slime/glue meaningful functionality with turntables
172174
- Finishing iron trapdoors to have a recipe and work properly
173175
- Adding an iron fence gate
174176

@@ -182,5 +184,6 @@ Known Issues
182184
- The CUD block recipe sucks
183185
- Sloped rails don't flatten out when the rail they're connected to is moved down by a piston
184186
- Block placers/breakers have lazy texturing
185-
- Exploit with platforms
186-
- Minecart hitboxes obstruct the rail they are placed on (maybe not an issue? Only needed for merged cart jank)
187+
- Minecart hitboxes obstruct the rail they are placed on (maybe not an issue? Only needed for merged cart jank)
188+
- Platforms delete tile entities
189+
- This file doesn't really explain new platform mechanics

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.1.12
13+
mod_version = 0.2.0
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package zero.test;
2+
import net.minecraft.src.*;
3+
import btw.AddonHandler;
4+
import btw.block.BTWBlocks;
5+
import btw.block.blocks.PistonBlockBase;
6+
import btw.block.blocks.TorchBlockBase;
7+
import btw.world.util.WorldUtils;
8+
import btw.client.render.entity.BlockLiftedByPlatformRenderer;
9+
import btw.entity.mechanical.platform.BlockLiftedByPlatformEntity;
10+
import com.prupe.mcpatcher.cc.ColorizeBlock;
11+
import com.prupe.mcpatcher.cc.Colorizer;
12+
import com.prupe.mcpatcher.ctm.CTMUtils;
13+
import com.prupe.mcpatcher.ctm.GlassPaneRenderer;
14+
import com.prupe.mcpatcher.mal.block.RenderBlocksUtils;
15+
import com.prupe.mcpatcher.renderpass.RenderPass;
16+
import net.fabricmc.api.EnvType;
17+
import net.fabricmc.api.Environment;
18+
import org.lwjgl.opengl.GL11;
19+
import org.lwjgl.opengl.GL12;
20+
import org.spongepowered.asm.mixin.Mixin;
21+
import org.spongepowered.asm.mixin.injection.At;
22+
import org.spongepowered.asm.mixin.injection.Redirect;
23+
import org.spongepowered.asm.mixin.injection.Inject;
24+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
25+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
26+
import org.spongepowered.asm.mixin.Overwrite;
27+
import org.spongepowered.asm.mixin.Final;
28+
import org.spongepowered.asm.mixin.Shadow;
29+
import org.spongepowered.asm.mixin.gen.Invoker;
30+
import zero.test.IBlockMixins;
31+
import zero.test.IWorldMixins;
32+
import zero.test.IBlockRedstoneWireMixins;
33+
//import zero.test.mixin.IRedstoneWireAccessMixins;
34+
import zero.test.IBlockRedstoneLogicMixins;
35+
//import zero.test.mixin.IRenderBlocksAccessMixins;
36+
import zero.test.IRenderBlocksMixins;
37+
// Block piston reactions
38+
//#define getInputSignal(...) func_94482_f(__VA_ARGS__)
39+
public class GenericBlockRenderer {
40+
private static RenderBlocks renderBlocks = new RenderBlocks();
41+
public static void render_block(RenderEngine render, Entity entity, double x, double y, double z, int blockId, int meta) {
42+
Block block = Block.blocksList[blockId];
43+
if (!((block)==null)) {
44+
// This is just ripped from falling sand
45+
GL11.glPushMatrix();
46+
GL11.glTranslatef((float)x, (float)y, (float)z);
47+
render.bindTexture("/terrain.png");
48+
GL11.glDisable(GL11.GL_LIGHTING);
49+
renderBlocks.blockAccess = entity.worldObj;
50+
Tessellator tessellator = Tessellator.instance;
51+
tessellator.startDrawingQuads();
52+
tessellator.setTranslation(
53+
-MathHelper.floor_double(entity.posX) - 0.5D,
54+
-MathHelper.floor_double(entity.posY) - 0.5D,
55+
-MathHelper.floor_double(entity.posZ) - 0.5D
56+
);
57+
block.currentBlockRenderer = renderBlocks;
58+
block.renderFallingBlock(
59+
renderBlocks,
60+
MathHelper.floor_double(entity.posX),
61+
MathHelper.floor_double(entity.posY),
62+
MathHelper.floor_double(entity.posZ),
63+
meta
64+
);
65+
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
66+
tessellator.draw();
67+
GL11.glEnable(GL11.GL_LIGHTING);
68+
GL11.glPopMatrix();
69+
}
70+
}
71+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ 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 boolean isPlacingBlock();
1211
public boolean isRetractingBase();
1312
public boolean hasLargeCenterHardPointToFacing(int x, int y, int z, int direction, boolean ignoreTransparency);
1413
public void getCollisionList(AxisAlignedBB maskBox, List list, Entity entity);

src/main/java/zero/test/IBlockMixins.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ default public boolean isBouncyWhenMoved(int direction, int meta) {
4242
default public boolean isStickyForEntitiesWhenMoved(int direction, int meta) {
4343
return false;
4444
}
45+
default public boolean canTransmitRotationHorizontallyOnTurntable(World world, int x, int y, int z, int direction) {
46+
return ((Block)(Object)this).canTransmitRotationHorizontallyOnTurntable(world, x, y, z);
47+
}
4548
default public boolean permanentlySupportsMortarBlocks(World world, int x, int y, int z, int direction) {
4649
return false;
4750
}

src/main/java/zero/test/IMovingPlatformEntityMixins.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
// Block piston reactions
33

44
public interface IMovingPlatformEntityMixins {
5+
public void setBlockId(int blockId);
6+
public int getBlockId();
7+
public void setBlockMeta(int blockMeta);
8+
public int getBlockMeta();
9+
//public void setStickySides(int sides);
10+
//public int getStickySides();
511
}
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
package zero.test;
2+
import net.minecraft.src.*;
3+
import btw.AddonHandler;
4+
import btw.block.BTWBlocks;
5+
import btw.block.blocks.PlatformBlock;
6+
import btw.block.blocks.AnchorBlock;
7+
import btw.entity.mechanical.platform.BlockLiftedByPlatformEntity;
8+
import btw.entity.mechanical.platform.MovingAnchorEntity;
9+
import btw.entity.mechanical.platform.MovingPlatformEntity;
10+
import btw.block.tileentity.PulleyTileEntity;
11+
import btw.item.util.ItemUtils;
12+
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.injection.At;
14+
import org.spongepowered.asm.mixin.injection.Redirect;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
18+
import org.spongepowered.asm.mixin.Overwrite;
19+
import org.spongepowered.asm.mixin.Final;
20+
import org.spongepowered.asm.mixin.Shadow;
21+
import org.spongepowered.asm.mixin.gen.Invoker;
22+
import zero.test.IWorldMixins;
23+
import zero.test.IBlockMixins;
24+
import zero.test.IMovingPlatformEntityMixins;
25+
//import zero.test.mixin.IAnchorBlockAccessMixins;
26+
import java.util.Random;
27+
// Block piston reactions
28+
29+
// I mean... they're already solid, right?
30+
public class PlatformResolver {
31+
private static final int PLATFORM_LIFT_LIMIT =
32+
25;
33+
// 7 just feels right
34+
private static final int PLATFORM_MAX_DISTANCE = 7;
35+
private static final int PLATFORM_LIST_LENGTH = PLATFORM_LIFT_LIMIT;
36+
// IDK how to properly calculate this, so just add a lot of extra space?
37+
private static final int LIFT_LIST_LENGTH = PLATFORM_LIFT_LIMIT * 5;
38+
private static final int PLATFORM_LIST_START_INDEX = 0;
39+
private static final int LIFT_LIST_START_INDEX = PLATFORM_LIST_START_INDEX + PLATFORM_LIST_LENGTH;
40+
private static final int PLATFORM_STATE_LIST_LENGTH = PLATFORM_LIST_LENGTH;
41+
private static final int LIFT_STATE_LIST_LENGTH = LIFT_LIST_LENGTH;
42+
private static final int PLATFORM_STATE_LIST_START_INDEX = 0;
43+
private static final int LIFT_STATE_LIST_START_INDEX = PLATFORM_STATE_LIST_START_INDEX + PLATFORM_STATE_LIST_LENGTH;
44+
private final long[] platform_blocks = new long[PLATFORM_LIST_LENGTH + LIFT_LIST_LENGTH];
45+
private final int[] data_list = new int[PLATFORM_STATE_LIST_LENGTH + LIFT_STATE_LIST_LENGTH];
46+
private long anchor_position;
47+
private int source_x;
48+
private int source_y;
49+
private int source_z;
50+
private int platform_index_global;
51+
private int lift_index_global;
52+
protected boolean addPlatformBlock(World world, int x, int y, int z, boolean isExtending) {
53+
int blockId = world.getBlockId(x, y, z);
54+
Block block = Block.blocksList[blockId];
55+
long packedPos;
56+
if (
57+
((block)==null) ||
58+
(packedPos = ((long)(z)<<12 +26|(long)((x)&0x3FFFFFF)<<12|((y)&0xFFF))) == anchor_position ||
59+
((IBlockMixins)block).getPlatformMobilityFlag(world, x, y, z) != 1
60+
) {
61+
;
62+
return true;
63+
}
64+
;
65+
for (int i = platform_index_global; --i >= PLATFORM_LIST_START_INDEX;) {
66+
if (platform_blocks[i] == packedPos) {
67+
return true;
68+
}
69+
}
70+
if (platform_index_global == (PLATFORM_LIST_START_INDEX + PLATFORM_LIST_LENGTH)) {
71+
;
72+
return false;
73+
}
74+
platform_blocks[platform_index_global] = packedPos;
75+
data_list[platform_index_global] = (((blockId)&0xFFFF)|((world.getBlockMetadata(x, y, z)))<<16);
76+
++platform_index_global;
77+
int move_direction = isExtending ? 0 : 1;
78+
int facing = 0;
79+
do {
80+
int nextX = x + Facing.offsetsXForSide[facing];
81+
int nextY = y + Facing.offsetsYForSide[facing];
82+
int nextZ = z + Facing.offsetsZForSide[facing];
83+
int neighborId = world.getBlockId(nextX, nextY, nextZ);
84+
Block neighborBlock = Block.blocksList[neighborId];
85+
if (!((neighborBlock)==null)) {
86+
packedPos = ((long)(nextZ)<<12 +26|(long)((nextX)&0x3FFFFFF)<<12|((nextY)&0xFFF));
87+
switch (((IBlockMixins)neighborBlock).getPlatformMobilityFlag(world, nextX, nextY, nextZ)) {
88+
case 1:
89+
;
90+
int diffX, diffY, diffZ;
91+
if ((diffX = nextX - source_x) < 0) diffX = -diffX;
92+
if ((diffY = nextY - source_y) < 0) diffY = -diffY;
93+
if ((diffZ = nextZ - source_z) < 0) diffZ = -diffZ;
94+
if (diffX + diffY + diffZ >= PLATFORM_MAX_DISTANCE) {
95+
return false;
96+
}
97+
if (!this.addPlatformBlock(world, nextX, nextY, nextZ, isExtending)) {
98+
return false;
99+
}
100+
break;
101+
case 0:
102+
;
103+
if (
104+
packedPos == anchor_position ||
105+
!(
106+
((IBlockMixins)block).isStickyForBlocks(world, x, y, z, facing) &&
107+
((IBlockMixins)neighborBlock).canBeStuckTo(world, nextX, nextY, nextZ, facing, blockId) &&
108+
!(
109+
((IBlockMixins)neighborBlock).getMobilityFlag(world, nextX, nextY, nextZ) != 4 &&
110+
!neighborBlock.canBlockBePulledByPiston(world, nextX, nextY, nextZ, move_direction)
111+
) &&
112+
(
113+
facing >= 2 ||
114+
(
115+
facing == move_direction
116+
? neighborBlock.canBlockBePushedByPiston(world, nextX, nextY, nextZ, facing)
117+
: neighborBlock.canBlockBePulledByPiston(world, nextX, nextY, nextZ, ((facing)^1))
118+
)
119+
)
120+
)
121+
) {
122+
break;
123+
}
124+
case 2: {
125+
;
126+
if (
127+
facing == 1 ||
128+
((IBlockMixins)block).isStickyForBlocks(world, x, y, z, facing)
129+
) {
130+
int i = lift_index_global;
131+
do {
132+
if (--i < LIFT_LIST_START_INDEX) {
133+
platform_blocks[lift_index_global] = packedPos;
134+
data_list[lift_index_global] = (((neighborId)&0xFFFF)|((world.getBlockMetadata(nextX, nextY, nextZ)))<<16);
135+
++lift_index_global;
136+
break;
137+
}
138+
} while (platform_blocks[i] != packedPos);
139+
}
140+
break;
141+
}
142+
}
143+
}
144+
} while (((++facing)<=5));
145+
return true;
146+
}
147+
public void liftBlocks(World world, int x, int y, int z, MovingAnchorEntity associatedAnchorEntity) {
148+
;
149+
anchor_position = ((long)(source_z = z)<<12 +26|(long)((source_x = x)&0x3FFFFFF)<<12|((y)&0xFFF));
150+
platform_index_global = PLATFORM_LIST_START_INDEX;
151+
lift_index_global = LIFT_LIST_START_INDEX;
152+
source_y = --y;
153+
if (this.addPlatformBlock(world, x, y, z, associatedAnchorEntity.motionY < 0.0D)) {
154+
long packedPos;
155+
;
156+
for (int i = lift_index_global; --i >= LIFT_LIST_START_INDEX;) {
157+
packedPos = platform_blocks[i];
158+
{(x)=((int)((packedPos)<<26>>(64)-26));(z)=((int)((packedPos)>>(64)-26));(y)=((int)(packedPos)<<(32)-12>>(32)-12);};
159+
int blockId;
160+
int blockMeta;
161+
int blockState = data_list[i];
162+
{(blockId)=((blockState)&0xFFFF);(blockMeta)=((blockState)>>>16);};
163+
Block block = Block.blocksList[blockId];
164+
blockMeta = ((IBlockMixins)block).adjustMetadataForPlatformMove(blockMeta);
165+
if (
166+
//blockId != BUFFER_STOP_ID &&
167+
((IBlockMixins)block).getMobilityFlag(world, x, y, z) != 1 &&
168+
!(block instanceof BlockRailBase)
169+
) {
170+
MovingPlatformEntity lifted_entity = (MovingPlatformEntity)EntityList.createEntityOfType(
171+
MovingPlatformEntity.class, world,
172+
(double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D,
173+
associatedAnchorEntity
174+
);
175+
((IMovingPlatformEntityMixins)lifted_entity).setBlockId(blockId);
176+
((IMovingPlatformEntityMixins)lifted_entity).setBlockMeta(blockMeta);
177+
world.spawnEntityInWorld(lifted_entity);
178+
}
179+
else {
180+
BlockLiftedByPlatformEntity lifted_entity = (BlockLiftedByPlatformEntity)EntityList.createEntityOfType(
181+
BlockLiftedByPlatformEntity.class, world,
182+
(double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D
183+
);
184+
lifted_entity.setBlockID(blockId);
185+
lifted_entity.setBlockMetadata(blockMeta);
186+
world.spawnEntityInWorld(lifted_entity);
187+
}
188+
world.setBlock(x, y, z, 0, 0, 0x02 | 0x08 | 0x20 | 0x40);
189+
}
190+
;
191+
for (int i = platform_index_global; --i >= PLATFORM_LIST_START_INDEX;) {
192+
packedPos = platform_blocks[i];
193+
{(x)=((int)((packedPos)<<26>>(64)-26));(z)=((int)((packedPos)>>(64)-26));(y)=((int)(packedPos)<<(32)-12>>(32)-12);};
194+
MovingPlatformEntity moving_entity = (MovingPlatformEntity)EntityList.createEntityOfType(
195+
MovingPlatformEntity.class, world,
196+
(double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D,
197+
associatedAnchorEntity
198+
);
199+
int blockId;
200+
int blockMeta;
201+
int blockState = data_list[i];
202+
{(blockId)=((blockState)&0xFFFF);(blockMeta)=((blockState)>>>16);};
203+
((IMovingPlatformEntityMixins)moving_entity).setBlockId(blockId);
204+
((IMovingPlatformEntityMixins)moving_entity).setBlockMeta(blockMeta);
205+
world.spawnEntityInWorld(moving_entity);
206+
world.setBlock(x, y, z, 0, 0, 0x02 | 0x08 | 0x20 | 0x40);
207+
}
208+
for (int i = lift_index_global; --i >= LIFT_LIST_START_INDEX;) {
209+
// Set x,y,z to position of block in lift list
210+
packedPos = platform_blocks[i];
211+
world.notifyBlocksOfNeighborChange(((int)((packedPos)<<26>>(64)-26)),((int)(packedPos)<<(32)-12>>(32)-12),((int)((packedPos)>>(64)-26)), ((data_list[i])&0xFFFF));
212+
//world.setBlock(BLOCK_POS_UNPACK_ARGS(packedPos), 0, 0, UPDATE_NEIGHBORS | UPDATE_CLIENTS | UPDATE_IMMEDIATE | UPDATE_SUPPRESS_DROPS | UPDATE_MOVE_BY_PISTON);
213+
}
214+
for (int i = platform_index_global; --i >= PLATFORM_LIST_START_INDEX;) {
215+
// Set x,y,z to position of block in platform list
216+
packedPos = platform_blocks[i];
217+
world.notifyBlocksOfNeighborChange(((int)((packedPos)<<26>>(64)-26)),((int)(packedPos)<<(32)-12>>(32)-12),((int)((packedPos)>>(64)-26)), ((data_list[i])&0xFFFF));
218+
//world.setBlock(BLOCK_POS_UNPACK_ARGS(packedPos), 0, 0, UPDATE_NEIGHBORS | UPDATE_CLIENTS | UPDATE_IMMEDIATE | UPDATE_SUPPRESS_DROPS | UPDATE_MOVE_BY_PISTON);
219+
}
220+
}
221+
}
222+
};

0 commit comments

Comments
 (0)