Implement EndGateway state

This commit is contained in:
Matthew 2016-03-16 20:50:55 -04:00 committed by md_5
parent 6efa87306b
commit da444904c2
3 changed files with 52 additions and 0 deletions

View File

@ -272,6 +272,8 @@ public class CraftBlock implements Block {
return new CraftDispenser(this);
case DROPPER:
return new CraftDropper(this);
case END_GATEWAY:
return new CraftEndGateway(this);
case HOPPER:
return new CraftHopper(this);
case MOB_SPAWNER:

View File

@ -0,0 +1,40 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityEndGateway;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.EndGateway;
import org.bukkit.craftbukkit.CraftWorld;
public class CraftEndGateway extends CraftBlockState implements EndGateway {
private TileEntityEndGateway gateway;
public CraftEndGateway(Block block) {
super(block);
CraftWorld world = (CraftWorld) block.getWorld();
gateway = (TileEntityEndGateway) world.getTileEntityAt(getX(), getY(), getZ());
}
public CraftEndGateway(final Material material, TileEntityEndGateway te) {
super(material);
this.gateway = te;
}
@Override
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
gateway.update();
}
return result;
}
@Override
public TileEntityEndGateway getTileEntity() {
return gateway;
}
}

View File

@ -15,6 +15,7 @@ import net.minecraft.server.TileEntityChest;
import net.minecraft.server.TileEntityCommand;
import net.minecraft.server.TileEntityDispenser;
import net.minecraft.server.TileEntityDropper;
import net.minecraft.server.TileEntityEndGateway;
import net.minecraft.server.TileEntityFurnace;
import net.minecraft.server.TileEntityHopper;
import net.minecraft.server.TileEntityMobSpawner;
@ -34,6 +35,7 @@ import org.bukkit.craftbukkit.block.CraftCommandBlock;
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
import org.bukkit.craftbukkit.block.CraftDispenser;
import org.bukkit.craftbukkit.block.CraftDropper;
import org.bukkit.craftbukkit.block.CraftEndGateway;
import org.bukkit.craftbukkit.block.CraftFurnace;
import org.bukkit.craftbukkit.block.CraftHopper;
import org.bukkit.craftbukkit.block.CraftJukebox;
@ -222,6 +224,11 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
te = new TileEntityDispenser();
}
return new CraftDropper(material, (TileEntityDropper) te);
case END_GATEWAY:
if (te == null) {
te = new TileEntityEndGateway();
}
return new CraftEndGateway(material, (TileEntityEndGateway) te);
case HOPPER:
if (te == null) {
te = new TileEntityHopper();
@ -304,6 +311,9 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
case DROPPER:
valid = te instanceof TileEntityDropper;
break;
case END_GATEWAY:
valid = te instanceof TileEntityEndGateway;
break;
case HOPPER:
valid = te instanceof TileEntityHopper;
break;