mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 23:45:44 +00:00
Regenerate patches with relative headers. This should lower conflicts in future PRs.
Convert Forge to use Official mappings. Mojang released their obfuscation mappings but we have not used them up until now due to wanting to get their license to be more explicitly permissive. It is clear that their intent is to allow us to use their names for developing mods like this. See the full wording, and our interpretation here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
This commit is contained in:
1 parent
802298d99d
commit
a95b968c13
832 files changed
+4464
-4373
No files matched your search
@@ -33,6 +33,8 @@ import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import net.minecraft.resources.IFutureReloadListener.IStage;
|
||||
|
||||
/**
|
||||
* The main ResourceManager is recreated on each reload, through {@link DataPackRegistries}'s creation.
|
||||
*
|
||||
|
||||
@@ -151,14 +151,14 @@ public class ForgeEventFactory
|
||||
public static boolean onMultiBlockPlace(@Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction)
|
||||
{
|
||||
BlockSnapshot snap = blockSnapshots.get(0);
|
||||
BlockState placedAgainst = snap.getWorld().getBlockState(snap.getPos().offset(direction.getOpposite()));
|
||||
BlockState placedAgainst = snap.getWorld().getBlockState(snap.getPos().relative(direction.getOpposite()));
|
||||
EntityMultiPlaceEvent event = new EntityMultiPlaceEvent(blockSnapshots, placedAgainst, entity);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onBlockPlace(@Nullable Entity entity, @Nonnull BlockSnapshot blockSnapshot, @Nonnull Direction direction)
|
||||
{
|
||||
BlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().offset(direction.getOpposite()));
|
||||
BlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().relative(direction.getOpposite()));
|
||||
EntityPlaceEvent event = new BlockEvent.EntityPlaceEvent(blockSnapshot, placedAgainst, entity);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class ForgeEventFactory
|
||||
{
|
||||
Result result = canEntitySpawn(entity, world, x, y, z, spawner, SpawnReason.SPAWNER);
|
||||
if (result == Result.DEFAULT)
|
||||
return entity.canSpawn(world, SpawnReason.SPAWNER) && entity.isNotColliding(world); // vanilla logic (inverted)
|
||||
return entity.checkSpawnRules(world, SpawnReason.SPAWNER) && entity.checkSpawnObstruction(world); // vanilla logic (inverted)
|
||||
else
|
||||
return result == Result.ALLOW;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public class ForgeEventFactory
|
||||
{
|
||||
LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity);
|
||||
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
|
||||
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnedInChunk();
|
||||
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnClusterSize();
|
||||
}
|
||||
|
||||
public static ITextComponent getPlayerDisplayName(PlayerEntity player, ITextComponent username)
|
||||
@@ -355,7 +355,7 @@ public class ForgeEventFactory
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
context.getItem().damageItem(1, context.getPlayer(), player -> player.sendBreakAnimation(context.getHand()));
|
||||
context.getItemInHand().hurtAndBreak(1, context.getPlayer(), player -> player.broadcastBreakEvent(context.getHand()));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -374,7 +374,7 @@ public class ForgeEventFactory
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
if (!world.isClientSide)
|
||||
stack.shrink(1);
|
||||
return 1;
|
||||
}
|
||||
@@ -389,15 +389,15 @@ public class ForgeEventFactory
|
||||
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
if (player.abilities.isCreativeMode)
|
||||
if (player.abilities.instabuild)
|
||||
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack);
|
||||
|
||||
stack.shrink(1);
|
||||
if (stack.isEmpty())
|
||||
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, event.getFilledBucket());
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
|
||||
player.dropItem(event.getFilledBucket(), false);
|
||||
if (!player.inventory.add(event.getFilledBucket()))
|
||||
player.drop(event.getFilledBucket(), false);
|
||||
|
||||
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack);
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class ForgeEventFactory
|
||||
public static int onItemExpire(ItemEntity entity, @Nonnull ItemStack item)
|
||||
{
|
||||
if (item.isEmpty()) return -1;
|
||||
ItemExpireEvent event = new ItemExpireEvent(entity, (item.isEmpty() ? 6000 : item.getItem().getEntityLifespan(item, entity.world)));
|
||||
ItemExpireEvent event = new ItemExpireEvent(entity, (item.isEmpty() ? 6000 : item.getItem().getEntityLifespan(item, entity.level)));
|
||||
if (!MinecraftForge.EVENT_BUS.post(event)) return -1;
|
||||
return event.getExtraLife();
|
||||
}
|
||||
@@ -435,11 +435,11 @@ public class ForgeEventFactory
|
||||
|
||||
public static boolean canMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting)
|
||||
{
|
||||
boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.world, isMounting));
|
||||
boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.level, isMounting));
|
||||
|
||||
if(isCanceled)
|
||||
{
|
||||
entityMounting.setPositionAndRotation(entityMounting.getPosX(), entityMounting.getPosY(), entityMounting.getPosZ(), entityMounting.prevRotationYaw, entityMounting.prevRotationPitch);
|
||||
entityMounting.absMoveTo(entityMounting.getX(), entityMounting.getY(), entityMounting.getZ(), entityMounting.yRotO, entityMounting.xRotO);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -522,7 +522,7 @@ public class ForgeEventFactory
|
||||
boolean changed = false;
|
||||
for (int x = 0; x < stacks.size(); x++)
|
||||
{
|
||||
changed |= ItemStack.areItemStacksEqual(tmp.get(x), stacks.get(x));
|
||||
changed |= ItemStack.matches(tmp.get(x), stacks.get(x));
|
||||
stacks.set(x, event.getItem(x));
|
||||
}
|
||||
if (changed)
|
||||
@@ -545,13 +545,13 @@ public class ForgeEventFactory
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static boolean renderFireOverlay(PlayerEntity player, MatrixStack mat)
|
||||
{
|
||||
return renderBlockOverlay(player, mat, OverlayType.FIRE, Blocks.FIRE.getDefaultState(), player.getPosition());
|
||||
return renderBlockOverlay(player, mat, OverlayType.FIRE, Blocks.FIRE.defaultBlockState(), player.blockPosition());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static boolean renderWaterOverlay(PlayerEntity player, MatrixStack mat)
|
||||
{
|
||||
return renderBlockOverlay(player, mat, OverlayType.WATER, Blocks.WATER.getDefaultState(), player.getPosition());
|
||||
return renderBlockOverlay(player, mat, OverlayType.WATER, Blocks.WATER.defaultBlockState(), player.blockPosition());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -588,9 +588,9 @@ public class ForgeEventFactory
|
||||
Result canContinueSleep = evt.getResult();
|
||||
if (canContinueSleep == Result.DEFAULT)
|
||||
{
|
||||
return player.getBedPosition().map(pos-> {
|
||||
BlockState state = player.world.getBlockState(pos);
|
||||
return state.getBlock().isBed(state, player.world, pos, player);
|
||||
return player.getSleepingPos().map(pos-> {
|
||||
BlockState state = player.level.getBlockState(pos);
|
||||
return state.getBlock().isBed(state, player.level, pos, player);
|
||||
}).orElse(false);
|
||||
}
|
||||
else
|
||||
@@ -604,7 +604,7 @@ public class ForgeEventFactory
|
||||
|
||||
Result canContinueSleep = evt.getResult();
|
||||
if (canContinueSleep == Result.DEFAULT)
|
||||
return !player.world.isDaytime();
|
||||
return !player.level.isDay();
|
||||
else
|
||||
return canContinueSleep == Result.ALLOW;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ public class ForgeEventFactory
|
||||
{
|
||||
LootTableLoadEvent event = new LootTableLoadEvent(name, table, lootTableManager);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return LootTable.EMPTY_LOOT_TABLE;
|
||||
return LootTable.EMPTY;
|
||||
return event.getTable();
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ public class ForgeEventFactory
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
Result result = event.getResult();
|
||||
return result == Result.DEFAULT ? world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) : result == Result.ALLOW;
|
||||
return result == Result.DEFAULT ? world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW;
|
||||
}
|
||||
|
||||
public static boolean saplingGrowTree(IWorld world, Random rand, BlockPos pos)
|
||||
|
||||
@@ -46,7 +46,7 @@ public class EntityAttributeCreationEvent extends Event implements IModBusEvent
|
||||
|
||||
public void put(EntityType<? extends LivingEntity> entity, AttributeModifierMap map)
|
||||
{
|
||||
if (GlobalEntityTypeAttributes.doesEntityHaveAttributes(entity))
|
||||
if (GlobalEntityTypeAttributes.hasSupplier(entity))
|
||||
throw new IllegalStateException("Duplicate GlobalEntityTypeAttributes entry: " + entity);
|
||||
this.map.put(entity, map);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv
|
||||
this.entityAttributes = mapIn;
|
||||
this.entityTypes = ImmutableList.copyOf(
|
||||
ForgeRegistries.ENTITIES.getValues().stream()
|
||||
.filter(GlobalEntityTypeAttributes::doesEntityHaveAttributes)
|
||||
.filter(GlobalEntityTypeAttributes::hasSupplier)
|
||||
.map(entityType -> (EntityType<? extends LivingEntity>) entityType)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
@@ -61,7 +61,7 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv
|
||||
{
|
||||
AttributeModifierMap.MutableAttribute attributes = entityAttributes.computeIfAbsent(entityType,
|
||||
(type) -> new AttributeModifierMap.MutableAttribute());
|
||||
attributes.createMutableAttribute(attribute, value);
|
||||
attributes.add(attribute, value);
|
||||
}
|
||||
|
||||
public void add(EntityType<? extends LivingEntity> entityType, Attribute attribute)
|
||||
@@ -71,7 +71,7 @@ public class EntityAttributeModificationEvent extends Event implements IModBusEv
|
||||
|
||||
public boolean has(EntityType<? extends LivingEntity> entityType, Attribute attribute)
|
||||
{
|
||||
AttributeModifierMap globalMap = GlobalEntityTypeAttributes.getAttributesForEntity(entityType);
|
||||
AttributeModifierMap globalMap = GlobalEntityTypeAttributes.getSupplier(entityType);
|
||||
return globalMap.hasAttribute(attribute) || (entityAttributes.get(entityType) != null && entityAttributes.get(entityType).hasAttribute(attribute));
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
{
|
||||
public AllowDespawn(MobEntity entity)
|
||||
{
|
||||
super(entity, entity.world, entity.getPosX(), entity.getPosY(), entity.getPosZ());
|
||||
super(entity, entity.level, entity.getX(), entity.getY(), entity.getZ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@ public class PotionEvent extends LivingEvent
|
||||
|
||||
public PotionRemoveEvent(LivingEntity living, Effect potion)
|
||||
{
|
||||
super(living, living.getActivePotionEffect(potion));
|
||||
super(living, living.getEffect(potion));
|
||||
this.potion = potion;
|
||||
}
|
||||
|
||||
public PotionRemoveEvent(LivingEntity living, EffectInstance effect)
|
||||
{
|
||||
super(living, effect);
|
||||
this.potion = effect.getPotion();
|
||||
this.potion = effect.getEffect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ItemFishedEvent extends PlayerEvent
|
||||
|
||||
public ItemFishedEvent(List<ItemStack> stacks, int rodDamage, FishingBobberEntity hook)
|
||||
{
|
||||
super(hook.func_234606_i_());
|
||||
super(hook.getPlayerOwner());
|
||||
this.stacks.addAll(stacks);
|
||||
this.rodDamage = rodDamage;
|
||||
this.hook = hook;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
|
||||
public EntityInteractSpecific(PlayerEntity player, Hand hand, Entity target, Vector3d localPos)
|
||||
{
|
||||
super(player, hand, target.getPosition(), null);
|
||||
super(player, hand, target.blockPosition(), null);
|
||||
this.localPos = localPos;
|
||||
this.target = target;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
|
||||
public EntityInteract(PlayerEntity player, Hand hand, Entity target)
|
||||
{
|
||||
super(player, hand, target.getPosition(), null);
|
||||
super(player, hand, target.blockPosition(), null);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
}
|
||||
|
||||
public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) {
|
||||
super(player, hand, pos, hitVec.getFace());
|
||||
super(player, hand, pos, hitVec.getDirection());
|
||||
this.hitVec = hitVec;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
{
|
||||
public RightClickItem(PlayerEntity player, Hand hand)
|
||||
{
|
||||
super(player, hand, player.getPosition(), null);
|
||||
super(player, hand, player.blockPosition(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
{
|
||||
public RightClickEmpty(PlayerEntity player, Hand hand)
|
||||
{
|
||||
super(player, hand, player.getPosition(), null);
|
||||
super(player, hand, player.blockPosition(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
{
|
||||
public LeftClickEmpty(PlayerEntity player)
|
||||
{
|
||||
super(player, Hand.MAIN_HAND, player.getPosition(), null);
|
||||
super(player, Hand.MAIN_HAND, player.blockPosition(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
@Nonnull
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return getPlayer().getHeldItem(hand);
|
||||
return getPlayer().getItemInHand(hand);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +366,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
*/
|
||||
public World getWorld()
|
||||
{
|
||||
return getPlayer().getEntityWorld();
|
||||
return getPlayer().getCommandSenderWorld();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,7 +374,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
*/
|
||||
public LogicalSide getSide()
|
||||
{
|
||||
return getWorld().isRemote ? LogicalSide.CLIENT : LogicalSide.SERVER;
|
||||
return getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -100,8 +100,8 @@ public class BlockEvent extends Event
|
||||
}
|
||||
else
|
||||
{
|
||||
int bonusLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getHeldItemMainhand());
|
||||
int silklevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand());
|
||||
int bonusLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, player.getMainHandItem());
|
||||
int silklevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, player.getMainHandItem());
|
||||
this.exp = state.getExpDrop(world, pos, bonusLevel, silklevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ExplosionEvent extends Event
|
||||
/** return the list of blocks affected by the explosion. */
|
||||
public List<BlockPos> getAffectedBlocks()
|
||||
{
|
||||
return getExplosion().getAffectedBlockPositions();
|
||||
return getExplosion().getToBlow();
|
||||
}
|
||||
|
||||
/** return the list of entities affected by the explosion. */
|
||||
|
||||
@@ -62,7 +62,7 @@ public abstract class PistonEvent extends BlockEvent
|
||||
*/
|
||||
public BlockPos getFaceOffsetPos()
|
||||
{
|
||||
return this.getPos().offset(direction);
|
||||
return this.getPos().relative(direction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user