Initial patch update to 1.12.

Some things to note:
Netty is screwy so currently can't join single player. @cpw
Crafting has been MAJORY reworked. The current GameRegistry functions are nooped, this is IN THE WORKS.
  Just need to move the recipe list to a full class registry, and then re implement the in-code recipe registration.
  Also, it IS advised that modders move to JSON, because ideally we'll see a S->C recipe syncing system in 1.13
  which would allow servers to have custom recipes.
  OreDictionary currently 1/2 works, need to write a better algorithm for replacing ingredients.
  Please be patient
Rendering:
  A lot of functions got a new float parameter, this is similar to partial ticks, needs more research
This commit is contained in:
LexManos authored and cpw committed 2017-06-10 22:22:02 -04:00
1 parent 286777b824
commit f1cca475ea
342 files changed
+3878 -2936

No files matched your search

@@ -0,0 +1,17 @@
package net.minecraftforge.items.wrapper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraftforge.items.IItemHandler;
/**
* Exposes the armor inventory of an {@link EntityLivingBase} as an {@link IItemHandler} using {@link EntityLivingBase#getItemStackFromSlot} and
* {@link EntityLivingBase#setItemStackToSlot}.
*/
public class EntityArmorInvWrapper extends EntityEquipmentInvWrapper
{
public EntityArmorInvWrapper(final EntityLivingBase entity)
{
super(entity, EntityEquipmentSlot.Type.ARMOR);
}
}
@@ -0,0 +1,170 @@
package net.minecraftforge.items.wrapper;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
/**
* Exposes the armor or hands inventory of an {@link EntityLivingBase} as an {@link IItemHandler} using {@link EntityLivingBase#getItemStackFromSlot} and
* {@link EntityLivingBase#setItemStackToSlot}.
*/
public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiable
{
/**
* The entity.
*/
protected final EntityLivingBase entity;
/**
* The slots exposed by this wrapper, with {@link EntityEquipmentSlot#index} as the index.
*/
protected final List<EntityEquipmentSlot> slots;
/**
* @param entity The entity.
* @param slotType The slot type to expose.
*/
public EntityEquipmentInvWrapper(final EntityLivingBase entity, final EntityEquipmentSlot.Type slotType)
{
this.entity = entity;
final List<EntityEquipmentSlot> slots = new ArrayList<EntityEquipmentSlot>();
for (final EntityEquipmentSlot slot : EntityEquipmentSlot.values())
{
if (slot.getSlotType() == slotType)
{
slots.add(slot);
}
}
this.slots = ImmutableList.copyOf(slots);
}
@Override
public int getSlots()
{
return slots.size();
}
@Nonnull
@Override
public ItemStack getStackInSlot(final int slot)
{
return entity.getItemStackFromSlot(validateSlotIndex(slot));
}
@Nonnull
@Override
public ItemStack insertItem(final int slot, @Nonnull final ItemStack stack, final boolean simulate)
{
if (stack.isEmpty())
return ItemStack.EMPTY;
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
final ItemStack existing = entity.getItemStackFromSlot(equipmentSlot);
int limit = getStackLimit(slot, stack);
if (!existing.isEmpty())
{
if (!ItemHandlerHelper.canItemStacksStack(stack, existing))
return stack;
limit -= existing.getCount();
}
if (limit <= 0)
return stack;
boolean reachedLimit = stack.getCount() > limit;
if (!simulate)
{
if (existing.isEmpty())
{
entity.setItemStackToSlot(equipmentSlot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
}
else
{
existing.grow(reachedLimit ? limit : stack.getCount());
}
}
return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - limit) : ItemStack.EMPTY;
}
@Nonnull
@Override
public ItemStack extractItem(final int slot, final int amount, final boolean simulate)
{
if (amount == 0)
return ItemStack.EMPTY;
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
final ItemStack existing = entity.getItemStackFromSlot(equipmentSlot);
if (existing.isEmpty())
return ItemStack.EMPTY;
final int toExtract = Math.min(amount, existing.getMaxStackSize());
if (existing.getCount() <= toExtract)
{
if (!simulate)
{
entity.setItemStackToSlot(equipmentSlot, ItemStack.EMPTY);
}
return existing;
}
else
{
if (!simulate)
{
entity.setItemStackToSlot(equipmentSlot, ItemHandlerHelper.copyStackWithSize(existing, existing.getCount() - toExtract));
}
return ItemHandlerHelper.copyStackWithSize(existing, toExtract);
}
}
@Override
public int getSlotLimit(final int slot)
{
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
return equipmentSlot.getSlotType() == EntityEquipmentSlot.Type.ARMOR ? 1 : 64;
}
protected int getStackLimit(final int slot, @Nonnull final ItemStack stack)
{
return Math.min(getSlotLimit(slot), stack.getMaxStackSize());
}
@Override
public void setStackInSlot(final int slot, @Nonnull final ItemStack stack)
{
final EntityEquipmentSlot equipmentSlot = validateSlotIndex(slot);
if (ItemStack.areItemStacksEqual(entity.getItemStackFromSlot(equipmentSlot), stack))
return;
entity.setItemStackToSlot(equipmentSlot, stack);
}
protected EntityEquipmentSlot validateSlotIndex(final int slot)
{
if (slot < 0 || slot >= slots.size())
throw new IllegalArgumentException("Slot " + slot + " not in valid range - [0," + slots.size() + ")");
return slots.get(slot);
}
}
@@ -0,0 +1,17 @@
package net.minecraftforge.items.wrapper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraftforge.items.IItemHandler;
/**
* Exposes the hands inventory of an {@link EntityLivingBase} as an {@link IItemHandler} using {@link EntityLivingBase#getItemStackFromSlot} and
* {@link EntityLivingBase#setItemStackToSlot}.
*/
public class EntityHandsInvWrapper extends EntityEquipmentInvWrapper
{
public EntityHandsInvWrapper(EntityLivingBase entity)
{
super(entity, EntityEquipmentSlot.Type.HAND);
}
}