Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
Minor 1.11.2 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed Apr 2, 2017
1 parent 040bcdc commit 5959c80
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private ContextHelpers() {
* @param list The list to get items from.
* @return The converted list.
*/
@Nullable
@Nonnull
public static Map<Integer, Map<Object, Object>> getMetaList(@Nonnull IPartialContext<?> context, @Nullable Collection<?> list) {
if (list == null) return Collections.emptyMap();

Expand All @@ -45,7 +45,7 @@ public static Map<Integer, Map<Object, Object>> getMetaList(@Nonnull IPartialCon
* @param list The list to get items from.
* @return The converted list.
*/
@Nullable
@Nonnull
public static Map<Integer, Map<Object, Object>> getMetaList(@Nonnull IPartialContext<?> context, @Nullable Object[] list) {
if (list == null) return Collections.emptyMap();

Expand All @@ -69,7 +69,7 @@ public static Map<Integer, Map<Object, Object>> getMetaList(@Nonnull IPartialCon
* @param list The list to get items from.
* @return The converted list.
*/
@Nullable
@Nonnull
public static Map<Integer, ILuaObject> getObjectList(@Nonnull IContext<?> context, @Nullable Collection<?> list) {
if (list == null) return Collections.emptyMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.squiddev.plethora.api.PlethoraAPI;
import org.squiddev.plethora.api.module.BasicModuleHandler;

import javax.annotation.Nonnull;

/**
* A {@link BasicModuleHandler} which also provides a {@link IMinecartUpgradeHandler}.
*/
Expand All @@ -24,13 +26,13 @@ protected IMinecartUpgradeHandler createMinecart() {


@Override
public boolean hasCapability(Capability<?> capability, EnumFacing enumFacing) {
public boolean hasCapability(@Nonnull Capability<?> capability, EnumFacing enumFacing) {
return super.hasCapability(capability, enumFacing) || capability == Constants.MINECART_UPGRADE_HANDLER_CAPABILITY;
}

@Override
@SuppressWarnings("unchecked")
public <T> T getCapability(Capability<T> capability, EnumFacing enumFacing) {
public <T> T getCapability(@Nonnull Capability<T> capability, EnumFacing enumFacing) {
if (capability == Constants.MINECART_UPGRADE_HANDLER_CAPABILITY) {
IMinecartUpgradeHandler upgrade = handler;
if (upgrade == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void doRender(@Nonnull EntityMinecartComputer entity, double x, double y,
IItemHandler handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
for (int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack stack = handler.getStackInSlot(slot);
if (stack != null) {
if (!stack.isEmpty()) {
GlStateManager.pushMatrix();
switch (slot) {
case 0: // Top
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private Object getBlockInfo(World world, BlockPos pos) {
table.put("metadata", metadata);

Map<Object, Object> stateTable = Maps.newHashMap();
for (Map.Entry<IProperty<?>, ?> entry : block.getActualState(state, world, pos).getProperties().entrySet()) {
for (Map.Entry<IProperty<?>, ?> entry : state.getActualState(world, pos).getProperties().entrySet()) {
String propertyName = entry.getKey().getName();
Object value = entry.getValue();
if (value instanceof String || value instanceof Number || value instanceof Boolean) {
Expand Down Expand Up @@ -220,12 +220,12 @@ public ITextComponent getDisplayName() {
}

@Override
public void addChatMessage(@Nonnull ITextComponent component) {
public void sendMessage(@Nonnull ITextComponent component) {
output.put(output.size() + 1, component.getUnformattedText());
}

@Override
public boolean canCommandSenderUseCommand(int permLevel, String commandName) {
public boolean canUseCommand(int permLevel, String commandName) {
return permLevel <= 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
Expand Down Expand Up @@ -77,7 +77,6 @@
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
import java.util.Arrays;

import static org.squiddev.plethora.api.Constants.MINECART_UPGRADE_HANDLER_CAPABILITY;
import static org.squiddev.plethora.gameplay.Plethora.ID;
Expand Down Expand Up @@ -135,8 +134,8 @@ public EntityMinecartComputer(World worldIn) {
for (int i = 0; i < SLOTS; i++) accesses[i] = new MinecartAccess(this);
}

public EntityMinecartComputer(EntityMinecartEmpty minecart, int id, String label, ComputerFamily family) {
super(minecart.getEntityWorld(), minecart.posX, minecart.posY, minecart.posZ);
public EntityMinecartComputer(EntityMinecartEmpty minecart, int id, String label, ComputerFamily family, int romId) {
this(minecart.getEntityWorld());

setPositionAndRotation(minecart.posX, minecart.posY, minecart.posZ, minecart.rotationYaw, minecart.rotationPitch);
motionX = minecart.motionX;
Expand Down Expand Up @@ -263,18 +262,19 @@ public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
if (slot >= 0) {
ItemStack heldStack = player.getHeldItem(hand);
ItemStack currentStack = itemHandler.getStackInSlot(slot);
if (heldStack == null && currentStack != null) {
if (heldStack.isEmpty() && !currentStack.isEmpty()) {
currentStack = itemHandler.extractItem(slot, 1, false);

if (!player.capabilities.isCreativeMode) {
Helpers.spawnItemStack(worldObj, posX, posY, posZ, currentStack);
Helpers.spawnItemStack(getEntityWorld(), posX, posY, posZ, currentStack);
}
} else if (heldStack != null && currentStack == null) {
} else if (!heldStack.isEmpty() && currentStack.isEmpty()) {
ItemStack copy = heldStack.copy();
copy.stackSize = 1;
copy.setCount(1);

if (itemHandler.insertItem(slot, copy, false) == null && !player.capabilities.isCreativeMode && --heldStack.stackSize <= 0) {
player.setHeldItem(hand, null);
if (itemHandler.insertItem(slot, copy, false).isEmpty() && !player.capabilities.isCreativeMode) {
heldStack.grow(-1);
if (heldStack.isEmpty()) player.setHeldItem(hand, ItemStack.EMPTY);
}
}

Expand Down Expand Up @@ -439,7 +439,7 @@ public void killMinecart(DamageSource source) {

for (int i = 0; i < SLOTS; i++) {
ItemStack child = itemHandler.getStackInSlot(i);
if (child != null) entityDropItem(child, 0);
if (!child.isEmpty()) entityDropItem(child, 0);
}
}
}
Expand Down Expand Up @@ -472,7 +472,7 @@ public boolean isUsable(EntityPlayer player) {
}
}

@Nonnull
@Nullable
@Override
@SuppressWarnings("unchecked")
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
Expand Down Expand Up @@ -664,7 +664,7 @@ public void startTracking(PlayerEvent.StartTracking event) {
for (int slot = 0; slot < SLOTS; slot++) {
ItemStack stack = handler.getStackInSlot(slot);
NBTTagCompound tag = minecart.accesses[slot].compound;
if (stack != null || tag != null) {
if (!stack.isEmpty() || tag != null) {
MessageMinecartSlot message = new MessageMinecartSlot(minecart, slot);
message.setStack(stack);
message.setTag(tag);
Expand Down Expand Up @@ -735,7 +735,7 @@ public void run() {
});
}

World world = Minecraft.getMinecraft().theWorld;
World world = Minecraft.getMinecraft().world;
if (world == null) return null;

Entity entity = world.getEntityByID(message.entityId);
Expand Down Expand Up @@ -763,14 +763,14 @@ public UpgradeItemHandler(int slots) {
protected void onContentsChanged(int slot) {
dirty |= 1 << slot;
ItemStack stack = getStackInSlot(slot);
handlers[slot] = stack == null ? null : stack.getCapability(MINECART_UPGRADE_HANDLER_CAPABILITY, null);
handlers[slot] = stack.isEmpty() ? null : stack.getCapability(MINECART_UPGRADE_HANDLER_CAPABILITY, null);
}

@Override
protected void onLoad() {
for (int i = 0; i < getSlots(); i++) {
ItemStack stack = getStackInSlot(i);
handlers[i] = stack == null ? null : stack.getCapability(MINECART_UPGRADE_HANDLER_CAPABILITY, null);
handlers[i] = stack.isEmpty() ? null : stack.getCapability(MINECART_UPGRADE_HANDLER_CAPABILITY, null);
}
}

Expand All @@ -787,8 +787,9 @@ public void clearDirty() {
dirty = 0;
}

@Nonnull
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
if (!stack.hasCapability(MINECART_UPGRADE_HANDLER_CAPABILITY, null)) {
return stack;
}
Expand All @@ -798,7 +799,7 @@ public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {

@Override
public String toString() {
return Arrays.toString(stacks);
return stacks.toString();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.squiddev.plethora.core.PlethoraCore;
import org.squiddev.plethora.utils.Helpers;

import javax.annotation.Nonnull;

import static org.squiddev.plethora.integration.computercraft.WirelessModemPeripheralBase.MinecartUpgradeHandler;
import static org.squiddev.plethora.integration.computercraft.WirelessModemPeripheralBase.PeripheralHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.monster.AbstractSkeleton;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayerMP;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/squiddev/plethora/utils/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.shared.util.IDAssigner;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
Expand Down

0 comments on commit 5959c80

Please sign in to comment.