Permalink
Browse files

Update for the new fuzzy system

  • Loading branch information...
me4502 committed Dec 27, 2018
1 parent c72c43c commit 92833518777242f676858a19beb81fbd6c826a60
@@ -175,12 +175,12 @@ public void onBlockRedstoneChange(final SourcedBlockRedstoneEvent event) {
@Override
public Block getBlockBase(Block trigger) throws InvalidMechanismException {
Block proximalBaseCenter = trigger.getRelative(BlockFace.UP);
if (trigger.getY() < trigger.getWorld().getMaxHeight()-1 && blocks.contains(BukkitAdapter.adapt(proximalBaseCenter.getBlockData())))
if (trigger.getY() < trigger.getWorld().getMaxHeight()-1 && Blocks.containsFuzzy(blocks, BukkitAdapter.adapt(proximalBaseCenter.getBlockData())))
return proximalBaseCenter; // On Top

// If we've reached this point nothing was found on the top, check the bottom
proximalBaseCenter = trigger.getRelative(BlockFace.DOWN);
if (trigger.getY() > 0 && blocks.contains(BukkitAdapter.adapt(proximalBaseCenter.getBlockData())))
if (trigger.getY() > 0 && Blocks.containsFuzzy(blocks, BukkitAdapter.adapt(proximalBaseCenter.getBlockData())))
return proximalBaseCenter; // it's below

proximalBaseCenter = trigger.getRelative(SignUtil.getBack(trigger));
@@ -299,10 +299,14 @@ public BlockData getBlockType(Block block) throws InvalidMechanismException {
BlockData type = null;
if (sign.getLine(0).contains(",")) {
type = BlockSyntax.getBukkitBlock(sign.getLine(0).split(",")[1]);
BlockData realType = this.getBlockBase(block).getBlockData();
if (type != null && realType.getMaterial() == type.getMaterial()) {
return realType;
}
}
if (type == null) {
type = this.getBlockBase(block).getBlockData();
sign.setLine(0, sign.getLine(0) + ',' + BlockSyntax.toMinifiedId(BukkitAdapter.adapt(type).toFuzzy()));
sign.setLine(0, sign.getLine(0) + ',' + BlockSyntax.toMinifiedId(BukkitAdapter.adapt(type).getBlockType().getFuzzyMatcher()));
sign.update(false);
}
return type;
@@ -448,7 +448,7 @@ public void onBlockBreak(BlockBreakEvent event) {
if (amount > 0) {
BlockState type = getGateBlock(sign, sign.getLine(1).equals("[DGate]"));
if(type == null || type.getBlockType().getMaterial().isAir())
type = BlockTypes.OAK_FENCE.getDefaultState().toFuzzy();
type = BlockTypes.OAK_FENCE.getFuzzyMatcher();
ItemStack toDrop = new ItemStack(BukkitAdapter.adapt(type.getBlockType()), amount);
event.getBlock().getWorld().dropItemNaturally(BlockUtil.getBlockCentre(event.getBlock()), toDrop);
}
@@ -503,7 +503,7 @@ public BlockState getGateBlock(ChangedSign sign, boolean smallSearchSize) {
}

if(enforceType && gateBlock != null && !gateBlock.getBlockType().getMaterial().isAir()) {
sign.setLine(0, BlockSyntax.toMinifiedId(gateBlock.toFuzzy()));
sign.setLine(0, BlockSyntax.toMinifiedId(gateBlock.getBlockType().getFuzzyMatcher()));
sign.update(false);
}
}

0 comments on commit 9283351

Please sign in to comment.