mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 13:09:59 +00:00
Entity patches progress.
This commit is contained in:
1 parent
e1b4a150c3
commit
dd32e74e34
101 files changed
+1753
-1822
No files matched your search
@@ -746,13 +746,6 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(new InputUpdateEvent(player, movementInput));
|
||||
}
|
||||
|
||||
public static String getHorseArmorTexture(EntityHorse horse, ItemStack armorStack)
|
||||
{
|
||||
String texture = armorStack.getItem().getHorseArmorTexture(horse, armorStack);
|
||||
if(texture == null) texture = horse.getHorseArmorType().getTextureName();
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static void refreshResources(Minecraft mc, VanillaResourceType... types) {
|
||||
SelectiveReloadStateHandler.INSTANCE.beginReload(ReloadRequirements.include(types));
|
||||
mc.refreshResources();
|
||||
|
||||
@@ -143,13 +143,22 @@ public class ForgeConfig
|
||||
LogManager.getLogger().debug(CORE, "Loaded FML config from {}", configFile);
|
||||
}
|
||||
|
||||
//TODO: Make this less duplciate? Maybe static CfgEntry<T> zombieBaseSummonChance = create((spec, name) -> spec.comment().translation().define(name), "zombieBaseSummonChance")
|
||||
public static class GENERAL
|
||||
{
|
||||
public static double zombieBaseSummonChance() {
|
||||
return ForgeConfig.INSTANCE.configData.<Double>getOrElse("general.zombieBaseSummonChance", (double)0.01F);
|
||||
}
|
||||
public static float zombieBabyChance() {
|
||||
return ForgeConfig.INSTANCE.configData.<Float>getOrElse("general.zombieBabyChance", 0.05F);
|
||||
}
|
||||
}
|
||||
|
||||
//General
|
||||
//public static boolean disableVersionCheck = false;
|
||||
//public static boolean removeErroringEntities = false;
|
||||
//public static boolean removeErroringTileEntities = false;
|
||||
//public static boolean fullBoundingBoxLadders = false;
|
||||
//public static double zombieSummonBaseChance = 0.1;
|
||||
//public static float zombieBabyChance = 0.05f;
|
||||
//public static boolean logCascadingWorldGeneration = true; // see Chunk#logCascadingWorldGeneration()
|
||||
//public static boolean fixVanillaCascading = false;
|
||||
//public static int dimensionUnloadQueueDelay = 0;
|
||||
|
||||
@@ -406,7 +406,7 @@ public class ForgeHooks
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src));
|
||||
}
|
||||
|
||||
public static boolean onLivingDrops(EntityLivingBase entity, DamageSource source, ArrayList<EntityItem> drops, int lootingLevel, boolean recentlyHit)
|
||||
public static boolean onLivingDrops(EntityLivingBase entity, DamageSource source, Collection<EntityItem> drops, int lootingLevel, boolean recentlyHit)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit));
|
||||
}
|
||||
|
||||
@@ -33,11 +33,15 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||
import com.electronwill.nightconfig.core.Config;
|
||||
import com.electronwill.nightconfig.core.ConfigFormat;
|
||||
import com.electronwill.nightconfig.core.InMemoryFormat;
|
||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||
import com.electronwill.nightconfig.core.utils.UnmodifiableConfigWrapper;
|
||||
import com.electronwill.nightconfig.core.ConfigSpec.CorrectionAction;
|
||||
import com.electronwill.nightconfig.core.ConfigSpec.CorrectionListener;
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -50,17 +54,16 @@ import com.google.common.collect.Lists;
|
||||
* and other things Forge configs would find useful.
|
||||
*/
|
||||
|
||||
public class ForgeConfigSpec
|
||||
public class ForgeConfigSpec extends UnmodifiableConfigWrapper<Config>
|
||||
{
|
||||
private final Config storage;
|
||||
private Map<List<String>, String> levelComments = new HashMap<>();
|
||||
private ForgeConfigSpec(Config storage, Map<List<String>, String> levelComments) {
|
||||
this.storage = storage;
|
||||
super(storage);
|
||||
this.levelComments = levelComments;
|
||||
}
|
||||
|
||||
public boolean isCorrect(CommentedConfig config) {
|
||||
return correct(storage, config, null, null, null, true) == 0;
|
||||
return correct(this.config, config, null, null, null, true) == 0;
|
||||
}
|
||||
|
||||
public int correct(CommentedConfig config) {
|
||||
@@ -68,7 +71,7 @@ public class ForgeConfigSpec
|
||||
}
|
||||
public int correct(CommentedConfig config, CorrectionListener listener) {
|
||||
LinkedList<String> parentPath = new LinkedList<>(); //Linked list for fast add/removes
|
||||
return correct(storage, config, parentPath, Collections.unmodifiableList(parentPath), listener, false);
|
||||
return correct(this.config, config, parentPath, Collections.unmodifiableList(parentPath), listener, false);
|
||||
}
|
||||
|
||||
private int correct(Config spec, CommentedConfig config, LinkedList<String> parentPath, List<String> parentPathUnmodifiable, CorrectionListener listener, boolean dryRun)
|
||||
@@ -166,6 +169,8 @@ public class ForgeConfigSpec
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private final Config storage = InMemoryFormat.withUniversalSupport().createConfig();
|
||||
|
||||
@@ -1054,4 +1054,17 @@ public interface IForgeBlock
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the top is consider 'solid'. This is a helper for getBlockFaceShape(UP) == SOLID.
|
||||
* Sadly some vanilla logic doesn't sync this value, so we have to have this special function.
|
||||
*
|
||||
* @param world The world
|
||||
* @param pos Block position in world
|
||||
* @return True if the top is considered solid
|
||||
*/
|
||||
default boolean isTopSolid(IBlockState state, IWorldReader world, BlockPos pos)
|
||||
{
|
||||
return state.isTopSolid();
|
||||
}
|
||||
}
|
||||
@@ -912,6 +912,19 @@ public interface IForgeBlockState
|
||||
return getBlockState().getBlock().isBurning(getBlockState(), world, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the top is consider 'solid'. This is a helper for getBlockFaceShape(UP) == SOLID.
|
||||
* Sadly some vanilla logic doesn't sync this value, so we have to have this special function.
|
||||
*
|
||||
* @param world The world
|
||||
* @param pos Block position in world
|
||||
* @return True if the top is considered solid
|
||||
*/
|
||||
default boolean isTopSolid(IWorldReader world, BlockPos pos)
|
||||
{
|
||||
return getBlockState().getBlock().isTopSolid(getBlockState(), world, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code PathNodeType} for this block. Return {@code null} for vanilla behavior.
|
||||
*
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.HorseArmorType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -269,10 +270,10 @@ public interface IForgeItem
|
||||
* for cleaner control over the update of the item without having to write a
|
||||
* subclass.
|
||||
*
|
||||
* @param entityItem The entity Item
|
||||
* @param entity The entity Item
|
||||
* @return Return true to skip any further update code.
|
||||
*/
|
||||
default boolean onEntityItemUpdate(net.minecraft.entity.item.EntityItem entityItem)
|
||||
default boolean onEntityItemUpdate(ItemStack stack, EntityItem entity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -421,11 +422,10 @@ public interface IForgeItem
|
||||
/**
|
||||
* Called when a entity tries to play the 'swing' animation.
|
||||
*
|
||||
* @param entityLiving The entity swinging the item.
|
||||
* @param stack The Item stack
|
||||
* @param entity The entity swinging the item.
|
||||
* @return True to cancel any further processing by EntityLiving
|
||||
*/
|
||||
default boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
|
||||
default boolean onEntitySwing(ItemStack stack, EntityLivingBase entity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -744,20 +744,15 @@ public interface IForgeItem
|
||||
return HorseArmorType.getByItem(stack.getItem());
|
||||
}
|
||||
|
||||
default String getHorseArmorTexture(EntityLiving wearer, ItemStack stack)
|
||||
{
|
||||
return getHorseArmorType(stack).getTextureName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick from {@link EntityHorse#onUpdate()} on the item in the
|
||||
* armor slot.
|
||||
*
|
||||
* @param stack the armor itemstack
|
||||
* @param world the world the horse is in
|
||||
* @param horse the horse wearing this armor
|
||||
* @param armor the armor itemstack
|
||||
*/
|
||||
default void onHorseArmorTick(World world, EntityLiving horse, ItemStack armor)
|
||||
default void onHorseArmorTick(ItemStack stack, World world, EntityLiving horse)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,23 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.block.state.BlockWorldState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.HorseArmorType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
|
||||
@@ -178,4 +187,117 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
|
||||
{
|
||||
return getStack().getItem().getItemEnchantability(getStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this to set a non-default armor slot for an ItemStack, but <em>do
|
||||
* not use this to get the armor slot of said stack; for that, use
|
||||
* {@link net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack)}.</em>
|
||||
*
|
||||
* @return the armor slot of the ItemStack, or {@code null} to let the default
|
||||
* vanilla logic as per {@code EntityLiving.getSlotForItemStack(stack)}
|
||||
* decide
|
||||
*/
|
||||
@Nullable
|
||||
default EntityEquipmentSlot getEquipmentSlot()
|
||||
{
|
||||
return getStack().getItem().getEquipmentSlot(getStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this Item disable a shield
|
||||
*
|
||||
* @param shield The shield in question
|
||||
* @param entity The EntityLivingBase holding the shield
|
||||
* @param attacker The EntityLivingBase holding the ItemStack
|
||||
* @retrun True if this ItemStack can disable the shield in question.
|
||||
*/
|
||||
default boolean canDisableShield(ItemStack shield, EntityLivingBase entity, EntityLivingBase attacker)
|
||||
{
|
||||
return getStack().getItem().canDisableShield(getStack(), shield, entity, attacker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Item a shield
|
||||
*
|
||||
* @param entity The Entity holding the ItemStack
|
||||
* @return True if the ItemStack is considered a shield
|
||||
*/
|
||||
default boolean isShield(@Nullable EntityLivingBase entity)
|
||||
{
|
||||
return getStack().getItem().isShield(getStack(), entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a entity tries to play the 'swing' animation.
|
||||
*
|
||||
* @param entity The entity swinging the item.
|
||||
* @return True to cancel any further processing by EntityLiving
|
||||
*/
|
||||
default boolean onEntitySwing(EntityLivingBase entity)
|
||||
{
|
||||
return getStack().getItem().onEntitySwing(getStack(), entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each tick while using an item.
|
||||
*
|
||||
* @param player The Player using the item
|
||||
* @param count The amount of time in tick the item has been used for
|
||||
* continuously
|
||||
*/
|
||||
default void onUsingTick(EntityLivingBase player, int count)
|
||||
{
|
||||
getStack().getItem().onUsingTick(getStack(), player, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the normal 'lifespan' of this item when it is dropped on the ground
|
||||
* as a EntityItem. This is in ticks, standard result is 6000, or 5 mins.
|
||||
*
|
||||
* @param world The world the entity is in
|
||||
* @return The normal lifespan in ticks.
|
||||
*/
|
||||
default int getEntityLifespan(World world)
|
||||
{
|
||||
return getStack().getItem().getEntityLifespan(getStack(), world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the default implemetation of EntityItem's onUpdate method, allowing
|
||||
* for cleaner control over the update of the item without having to write a
|
||||
* subclass.
|
||||
*
|
||||
* @param entity The entity Item
|
||||
* @return Return true to skip any further update code.
|
||||
*/
|
||||
default boolean onEntityItemUpdate(EntityItem entity)
|
||||
{
|
||||
return getStack().getItem().onEntityItemUpdate(getStack(), entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enum constant of type {@code HorseArmorType}. The returned enum
|
||||
* constant will be used to determine the armor value and texture of this item
|
||||
* when equipped.
|
||||
*
|
||||
* @return an enum constant of type {@code HorseArmorType}. Return
|
||||
* HorseArmorType.NONE if this is not horse armor
|
||||
*/
|
||||
default HorseArmorType getHorseArmorType()
|
||||
{
|
||||
return getStack().getItem().getHorseArmorType(getStack());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called every tick from {@link EntityHorse#onUpdate()} on the item in the
|
||||
* armor slot.
|
||||
*
|
||||
* @param world the world the horse is in
|
||||
* @param horse the horse wearing this armor
|
||||
*/
|
||||
default void onHorseArmorTick(World world, EntityLiving horse)
|
||||
{
|
||||
getStack().getItem().onHorseArmorTick(getStack(), world, horse);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
package net.minecraftforge.event.entity.living;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -52,11 +52,11 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
public class LivingDropsEvent extends LivingEvent
|
||||
{
|
||||
private final DamageSource source;
|
||||
private final List<EntityItem> drops;
|
||||
private final Collection<EntityItem> drops;
|
||||
private final int lootingLevel;
|
||||
private final boolean recentlyHit;
|
||||
|
||||
public LivingDropsEvent(EntityLivingBase entity, DamageSource source, List<EntityItem> drops, int lootingLevel, boolean recentlyHit)
|
||||
public LivingDropsEvent(EntityLivingBase entity, DamageSource source, Collection<EntityItem> drops, int lootingLevel, boolean recentlyHit)
|
||||
{
|
||||
super(entity);
|
||||
this.source = source;
|
||||
@@ -70,7 +70,7 @@ public class LivingDropsEvent extends LivingEvent
|
||||
return source;
|
||||
}
|
||||
|
||||
public List<EntityItem> getDrops()
|
||||
public Collection<EntityItem> getDrops()
|
||||
{
|
||||
return drops;
|
||||
}
|
||||
|
||||
@@ -351,8 +351,8 @@ public class VillagerRegistry
|
||||
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
|
||||
}
|
||||
|
||||
if (prof != entity.getForgeProfession())
|
||||
entity.setForgeProfession(prof);
|
||||
if (prof != entity.getProfessionForge())
|
||||
entity.setProfession(prof);
|
||||
}
|
||||
|
||||
@Deprecated public static VillagerProfession getById(int network){ return INSTANCE.REGISTRY.get(network); }
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -192,4 +193,14 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
|
||||
|
||||
return slots.get(slot);
|
||||
}
|
||||
|
||||
public static OptionalCapabilityInstance<IItemHandlerModifiable>[] create(EntityLivingBase entity)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
OptionalCapabilityInstance<IItemHandlerModifiable>[] ret = new OptionalCapabilityInstance[3];
|
||||
ret[0] = OptionalCapabilityInstance.of(() -> new EntityHandsInvWrapper(entity));
|
||||
ret[1] = OptionalCapabilityInstance.of(() -> new EntityArmorInvWrapper(entity));
|
||||
ret[2] = OptionalCapabilityInstance.of(() -> new CombinedInvWrapper(ret[0].orElse(null), ret[1].orElse(null)));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user