Skip to content

Commit

Permalink
0.05: look getBlock*() up in queue
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Jan 24, 2015
1 parent 2571662 commit c33bfe0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.LinkedList;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
Expand Down Expand Up @@ -130,4 +131,22 @@ public String getDescription() {
return description;
}
}

public IBlockState getBlockState(World world, BlockPos pos) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();

synchronized(setBlockStateQueue) {
for (int i = setBlockStateQueue.size() - 1 ; i >= 0 ; i--) {
SetBlockState entry = setBlockStateQueue.get(i);
BlockPos qPos = entry.pos;
if (qPos.getX() == x && qPos.getZ() == z && qPos.getY() == y) {
return entry.state;
}
}
}

return world.getBlockState(pos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ private void runCommand(Minecraft mc, EntityPlayerSP player,
String cmd, String args, Scanner scan) throws InputMismatchException, NoSuchElementException,
IndexOutOfBoundsException {
if (cmd.equals(GETBLOCK)) {
DesktopBlock b = new DesktopBlock(world.getBlockState(getPosition(scan)));
DesktopBlock b = new DesktopBlock(eventHandler.getBlockState(world, getPosition(scan)));

sendLine(b.toAPIBlock().id);
}
else if (cmd.equals(GETBLOCKWITHDATA)) {
APIBlock b = new DesktopBlock(world.getBlockState(getPosition(scan))).toAPIBlock();
APIBlock b = new DesktopBlock(eventHandler.getBlockState(world, getPosition(scan))).toAPIBlock();
sendLine(""+b.id+","+b.meta);
}
else if (cmd.equals(GETHEIGHT)) {
Expand All @@ -192,6 +192,7 @@ else if (cmd.equals(SETBLOCK)) {
int id = scan.nextInt();
int meta = scan.hasNextInt() ? scan.nextInt() : 0;
IBlockState state = new DesktopBlock(new APIBlock(id, meta)).getBlockState();
eventHandler.queueSetBlockState(new BlockPos(pos), state);
}
else if (cmd.equals(SETBLOCKS)) {
BlockPos pos1 = getPosition(scan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class RaspberryJamMod
{
public static final String MODID = "raspberryjammod";
public static final String VERSION = "0.04";
public static final String VERSION = "0.05";
public static final String NAME = "Raspberry Jam Mod";
private MinecraftCommunicator mcc;

Expand All @@ -47,9 +47,7 @@ public void onServerStopping(FMLServerStoppingEvent event) {
}

@EventHandler
public void onServerStarting(FMLServerStartingEvent event) // FMLInitializationEvent event)
{
// some example code
public void onServerStarting(FMLServerStartingEvent event) {
System.out.println("Raspberry Jam Mod started");

final MCEventHandler eventHandler = new MCEventHandler();
Expand Down

0 comments on commit c33bfe0

Please sign in to comment.