Skip to content

Commit

Permalink
Slowly progressing through advanced drawbridges
Browse files Browse the repository at this point in the history
  • Loading branch information
fuj1n committed Sep 5, 2018
1 parent d16f0dd commit 5e52461
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
8 changes: 4 additions & 4 deletions build.properties
Expand Up @@ -2,10 +2,10 @@ mod_version=2.0
minecraft_version=1.12.2
forge_version=14.23.4.2705

mappings_version=snapshot_20180722
mappings_version=stable_39

mantle_version=1.3.2.25
tinkers_version=2.9.1.70
mantle_version=1.3.2.+
tinkers_version=2.10.1.+

jei_version=4.9.+
jei_version=4.12.+
hwyla_version=1.8.26-B41
@@ -1,5 +1,6 @@
package slimeknights.tmechworks.blocks.logic.drawbridge;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
Expand All @@ -10,11 +11,36 @@
import slimeknights.tmechworks.client.gui.GuiDrawbridgeAdvanced;
import slimeknights.tmechworks.inventory.ContainerDrawbridgeAdvanced;

import java.util.Arrays;

public class AdvancedDrawbridgeLogic extends DrawbridgeLogic {
private IBlockState[] placedState;

public AdvancedDrawbridgeLogic(){
super(16);
}

@Override
public IBlockState getPlacedState(){
if(placedState == null || getExtendState() >= placedState.length)
return null;

return placedState[getExtendState() - 1];
}

@Override
public void setPlacedState(IBlockState state){
if(placedState == null)
placedState = new IBlockState[getStats().extendLength];
else if(placedState.length != getStats().extendLength)
placedState = Arrays.copyOf(placedState, getStats().extendLength);

if(getExtendState() >= placedState.length)
return;

placedState[getExtendState()] = state;
}

@Override
public int getNextIndex() {
return getExtendState();
Expand Down
Expand Up @@ -60,6 +60,14 @@ public ItemStack getLastBlock() {
return getStackInSlot(getLastIndex());
}

public IBlockState getPlacedState(){
return placedState;
}

public void setPlacedState(IBlockState state){
placedState = state;
}

public void subtractNextBlock() {
decrStackSize(getNextIndex(), 1);
ItemStack stack = getStackInSlot(getNextIndex());
Expand Down Expand Up @@ -186,7 +194,7 @@ public boolean placeBlock(BlockPos position) {
world.markAndNotifyBlock(snap.getPos(), null, oldBlock, newBlock, updateFlag);
}

placedState = state;
setPlacedState(state);
}

return placed;
Expand All @@ -206,11 +214,12 @@ public boolean breakBlock(BlockPos position) {

NonNullList<ItemStack> drops = getBlockDrops(position);

if(stack.isEmpty() && placedState != null){
if(stack.isEmpty() && getPlacedState() != null){
ItemStack foundDrop = ItemStack.EMPTY;

for(ItemStack drop : drops){
if(drop.getCount() == 1 && drop.getItem() == Item.getItemFromBlock(placedState.getBlock())){
//TODO Looks like a bug, the check doesn't match the one below
if(drop.getCount() == 1 && drop.getItem() == Item.getItemFromBlock(getPlacedState().getBlock())){
foundDrop = drop;
break;
}
Expand Down

0 comments on commit 5e52461

Please sign in to comment.