Lectern Controller edge cases

- When a Lectern Controller that a player is using is broken, they are no longer prevented from using any other Lectern Controllers
- Fixed weirdness when activating a Lectern Controller while holding another Linked Controller
This commit is contained in:
reidbhuntley 2021-07-10 21:52:11 -04:00
parent 4a57b916ff
commit da9c306ed5
4 changed files with 24 additions and 6 deletions

View file

@ -156,6 +156,10 @@ public class LecternControllerTileEntity extends SmartTileEntity {
}
public void dropController(BlockState state) {
Entity playerEntity = ((ServerWorld) world).getEntityByUuid(user);
if (playerEntity instanceof PlayerEntity)
stopUsing((PlayerEntity) playerEntity);
Direction dir = state.get(LecternControllerBlock.FACING);
double x = pos.getX() + 0.5 + 0.25*dir.getXOffset();
double y = pos.getY() + 1;

View file

@ -9,6 +9,7 @@ import java.util.Vector;
import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.CreateClient;
@ -147,6 +148,13 @@ public class LinkedControllerClientHandler {
}
}
if (inLectern() && AllBlocks.LECTERN_CONTROLLER.get().getTileEntityOptional(mc.world, lecternPos)
.map(te -> !te.isUsedBy(mc.player))
.orElse(true)) {
deactivateInLectern();
return;
}
if (mc.currentScreen != null) {
MODE = Mode.IDLE;
onReset();

View file

@ -70,6 +70,9 @@ public class LinkedControllerItem extends Item implements INamedContainerProvide
}
return ActionResultType.SUCCESS;
}
if (AllBlocks.LECTERN_CONTROLLER.has(hitState))
return ActionResultType.PASS;
}
}

View file

@ -79,11 +79,6 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere
boolean noControllerInMain = !AllItems.LINKED_CONTROLLER.isIn(mc.player.getHeldItemMainhand());
if (transformType == mainHand || (transformType == offHand && noControllerInMain)) {
float equip = equipProgress.getValue(pt);
int handModifier = transformType == TransformType.FIRST_PERSON_LEFT_HAND ? -1 : 1;
msr.translate(0, equip / 4, equip / 4 * handModifier);
msr.rotateY(equip * -30 * handModifier);
msr.rotateZ(equip * -30);
active = true;
}
@ -94,8 +89,16 @@ public class LinkedControllerItemRenderer extends CustomRenderedItemModelRendere
active = true;
}
active &= LinkedControllerClientHandler.MODE != Mode.IDLE;
active &= LinkedControllerClientHandler.MODE != Mode.IDLE && !LinkedControllerClientHandler.inLectern();
usedByMe = active;
if (active && (transformType == mainHand || transformType == offHand)) {
float equip = equipProgress.getValue(pt);
int handModifier = transformType == TransformType.FIRST_PERSON_LEFT_HAND ? -1 : 1;
msr.translate(0, equip / 4, equip / 4 * handModifier);
msr.rotateY(equip * -30 * handModifier);
msr.rotateZ(equip * -30);
}
}
renderer.render(active ? model.getPartial("powered") : model.getOriginalModel(), light);