Close Call
- Fixed belt splicing not using or refunding belt connectors - Fixed server crash when opening toolbox
This commit is contained in:
parent
0bc26ac7b0
commit
3e1312e695
3 changed files with 27 additions and 13 deletions
|
@ -71,10 +71,10 @@ public class BeltSlicer {
|
||||||
BeltPart part = state.getValue(BeltBlock.PART);
|
BeltPart part = state.getValue(BeltBlock.PART);
|
||||||
List<BlockPos> beltChain = BeltBlock.getBeltChain(world, controllerTE.getBlockPos());
|
List<BlockPos> beltChain = BeltBlock.getBeltChain(world, controllerTE.getBlockPos());
|
||||||
boolean creative = player.isCreative();
|
boolean creative = player.isCreative();
|
||||||
|
|
||||||
// Shorten from End
|
// Shorten from End
|
||||||
if (hoveringEnd(state, hit)) {
|
if (hoveringEnd(state, hit)) {
|
||||||
if (world.isClientSide)
|
if (world.isClientSide)
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
for (BlockPos blockPos : beltChain) {
|
for (BlockPos blockPos : beltChain) {
|
||||||
|
@ -160,26 +160,37 @@ public class BeltSlicer {
|
||||||
requiredShafts++;
|
requiredShafts++;
|
||||||
|
|
||||||
int amountRetrieved = 0;
|
int amountRetrieved = 0;
|
||||||
|
boolean beltFound = false;
|
||||||
Search: while (true) {
|
Search: while (true) {
|
||||||
for (int i = 0; i < player.inventory.getContainerSize(); ++i) {
|
for (int i = 0; i < player.inventory.getContainerSize(); ++i) {
|
||||||
if (amountRetrieved == requiredShafts)
|
if (amountRetrieved == requiredShafts && beltFound)
|
||||||
break Search;
|
break Search;
|
||||||
|
|
||||||
ItemStack itemstack = player.inventory.getItem(i);
|
ItemStack itemstack = player.inventory.getItem(i);
|
||||||
if (itemstack.isEmpty())
|
if (itemstack.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
int count = itemstack.getCount();
|
int count = itemstack.getCount();
|
||||||
|
|
||||||
|
if (AllItems.BELT_CONNECTOR.isIn(itemstack)) {
|
||||||
|
if (!world.isClientSide)
|
||||||
|
itemstack.shrink(1);
|
||||||
|
beltFound = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (AllBlocks.SHAFT.isIn(itemstack)) {
|
if (AllBlocks.SHAFT.isIn(itemstack)) {
|
||||||
int taken = Math.min(count, requiredShafts - amountRetrieved);
|
int taken = Math.min(count, requiredShafts - amountRetrieved);
|
||||||
if (taken == count)
|
if (!world.isClientSide)
|
||||||
player.inventory.setItem(i, ItemStack.EMPTY);
|
if (taken == count)
|
||||||
else
|
player.inventory.setItem(i, ItemStack.EMPTY);
|
||||||
itemstack.shrink(taken);
|
else
|
||||||
|
itemstack.shrink(taken);
|
||||||
amountRetrieved += taken;
|
amountRetrieved += taken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack(amountRetrieved));
|
if (!world.isClientSide)
|
||||||
|
player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack(amountRetrieved));
|
||||||
return ActionResultType.FAIL;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,8 +344,10 @@ public class BeltSlicer {
|
||||||
state.setValue(BeltBlock.CASING, segmentTE != null && segmentTE.casing != CasingType.NONE)
|
state.setValue(BeltBlock.CASING, segmentTE != null && segmentTE.casing != CasingType.NONE)
|
||||||
.setValue(BeltBlock.PART, BeltPart.MIDDLE));
|
.setValue(BeltBlock.PART, BeltPart.MIDDLE));
|
||||||
|
|
||||||
if (!creative)
|
if (!creative) {
|
||||||
player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack(2));
|
player.inventory.placeItemBackInInventory(world, AllBlocks.SHAFT.asStack(2));
|
||||||
|
player.inventory.placeItemBackInInventory(world, AllItems.BELT_CONNECTOR.asStack());
|
||||||
|
}
|
||||||
|
|
||||||
// Transfer items to other controller
|
// Transfer items to other controller
|
||||||
BlockPos search = controllerTE.getBlockPos();
|
BlockPos search = controllerTE.getBlockPos();
|
||||||
|
@ -449,7 +462,7 @@ public class BeltSlicer {
|
||||||
|
|
||||||
Feedback feedback = new Feedback();
|
Feedback feedback = new Feedback();
|
||||||
|
|
||||||
// TODO: Populate feedback in the methods for clientside
|
// TODO: Populate feedback in the methods for clientside
|
||||||
if (AllItems.WRENCH.isIn(held) || AllItems.WRENCH.isIn(heldOffHand))
|
if (AllItems.WRENCH.isIn(held) || AllItems.WRENCH.isIn(heldOffHand))
|
||||||
useWrench(state, world, pos, mc.player, Hand.MAIN_HAND, result, feedback);
|
useWrench(state, world, pos, mc.player, Hand.MAIN_HAND, result, feedback);
|
||||||
else if (AllItems.BELT_CONNECTOR.isIn(held) || AllItems.BELT_CONNECTOR.isIn(heldOffHand))
|
else if (AllItems.BELT_CONNECTOR.isIn(held) || AllItems.BELT_CONNECTOR.isIn(heldOffHand))
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
@ -366,9 +367,9 @@ public class ToolboxTileEntity extends SmartTileEntity implements INamedContaine
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getDisplayName() {
|
public ITextComponent getDisplayName() {
|
||||||
return customName != null ? customName
|
return customName != null ? customName
|
||||||
: AllBlocks.TOOLBOXES.get(getColor())
|
: new TranslationTextComponent(AllBlocks.TOOLBOXES.get(getColor())
|
||||||
.get()
|
.get()
|
||||||
.getName();
|
.getDescriptionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class ClientEvents {
|
||||||
// ScreenOpener.tick();
|
// ScreenOpener.tick();
|
||||||
ServerSpeedProvider.clientTick();
|
ServerSpeedProvider.clientTick();
|
||||||
BeltConnectorHandler.tick();
|
BeltConnectorHandler.tick();
|
||||||
BeltSlicer.tickHoveringInformation();
|
// BeltSlicer.tickHoveringInformation();
|
||||||
FilteringRenderer.tick();
|
FilteringRenderer.tick();
|
||||||
LinkRenderer.tick();
|
LinkRenderer.tick();
|
||||||
ScrollValueRenderer.tick();
|
ScrollValueRenderer.tick();
|
||||||
|
|
Loading…
Reference in a new issue