mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Most client patches done except the render pipeline.
Someone who has more in depth knowledge of that rendering system will need to do it.
This commit is contained in:
1 parent
b687180e12
commit
bf9158172f
109 files changed
+1597
-2275
No files matched your search
@@ -300,161 +300,6 @@ public class ForgeHooks
|
||||
*/
|
||||
public static boolean onPickBlock(RayTraceResult target, EntityPlayer player, World world)
|
||||
{
|
||||
/*
|
||||
boolean flag = this.player.capabilities.isCreativeMode;
|
||||
TileEntity tileentity = null;
|
||||
ItemStack itemstack;
|
||||
|
||||
if (this.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
BlockPos blockpos = this.objectMouseOver.getBlockPos();
|
||||
IBlockState iblockstate = this.world.getBlockState(blockpos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (iblockstate.getMaterial() == Material.AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
itemstack = block.getItem(this.world, blockpos, iblockstate);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag && GuiScreen.isCtrlKeyDown() && block.hasTileEntity())
|
||||
{
|
||||
tileentity = this.world.getTileEntity(blockpos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.objectMouseOver.typeOfHit != RayTraceResult.Type.ENTITY || this.objectMouseOver.entityHit == null || !flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.objectMouseOver.entityHit instanceof EntityPainting)
|
||||
{
|
||||
itemstack = new ItemStack(Items.PAINTING);
|
||||
}
|
||||
else if (this.objectMouseOver.entityHit instanceof EntityLeashKnot)
|
||||
{
|
||||
itemstack = new ItemStack(Items.LEAD);
|
||||
}
|
||||
else if (this.objectMouseOver.entityHit instanceof EntityItemFrame)
|
||||
{
|
||||
EntityItemFrame entityitemframe = (EntityItemFrame)this.objectMouseOver.entityHit;
|
||||
ItemStack itemstack1 = entityitemframe.getDisplayedItem();
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
itemstack = new ItemStack(Items.ITEM_FRAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = itemstack1.copy();
|
||||
}
|
||||
}
|
||||
else if (this.objectMouseOver.entityHit instanceof EntityMinecart)
|
||||
{
|
||||
EntityMinecart entityminecart = (EntityMinecart)this.objectMouseOver.entityHit;
|
||||
Item item;
|
||||
|
||||
switch (entityminecart.getType())
|
||||
{
|
||||
case FURNACE:
|
||||
item = Items.FURNACE_MINECART;
|
||||
break;
|
||||
case CHEST:
|
||||
item = Items.CHEST_MINECART;
|
||||
break;
|
||||
case TNT:
|
||||
item = Items.TNT_MINECART;
|
||||
break;
|
||||
case HOPPER:
|
||||
item = Items.HOPPER_MINECART;
|
||||
break;
|
||||
case COMMAND_BLOCK:
|
||||
item = Items.COMMAND_BLOCK_MINECART;
|
||||
break;
|
||||
default:
|
||||
item = Items.MINECART;
|
||||
}
|
||||
|
||||
itemstack = new ItemStack(item);
|
||||
}
|
||||
else if (this.objectMouseOver.entityHit instanceof EntityBoat)
|
||||
{
|
||||
itemstack = new ItemStack(((EntityBoat)this.objectMouseOver.entityHit).getItemBoat());
|
||||
}
|
||||
else if (this.objectMouseOver.entityHit instanceof EntityArmorStand)
|
||||
{
|
||||
itemstack = new ItemStack(Items.ARMOR_STAND);
|
||||
}
|
||||
else if (this.objectMouseOver.entityHit instanceof EntityEnderCrystal)
|
||||
{
|
||||
itemstack = new ItemStack(Items.END_CRYSTAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceLocation resourcelocation = EntityList.func_191301_a(this.objectMouseOver.entityHit);
|
||||
|
||||
if (resourcelocation == null || !EntityList.ENTITY_EGGS.containsKey(resourcelocation))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
itemstack = new ItemStack(Items.SPAWN_EGG);
|
||||
ItemMonsterPlacer.applyEntityIdToItemStack(itemstack, resourcelocation);
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
String s = "";
|
||||
|
||||
if (this.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
s = ((ResourceLocation)Block.REGISTRY.getNameForObject(this.world.getBlockState(this.objectMouseOver.getBlockPos()).getBlock())).toString();
|
||||
}
|
||||
else if (this.objectMouseOver.typeOfHit == RayTraceResult.Type.ENTITY)
|
||||
{
|
||||
s = EntityList.func_191301_a(this.objectMouseOver.entityHit).toString();
|
||||
}
|
||||
|
||||
LOGGER.warn("Picking on: [{}] {} gave null item", new Object[] {this.objectMouseOver.typeOfHit, s});
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryPlayer inventoryplayer = this.player.inventory;
|
||||
|
||||
if (tileentity != null)
|
||||
{
|
||||
this.storeTEInStack(itemstack, tileentity);
|
||||
}
|
||||
|
||||
int i = inventoryplayer.getSlotFor(itemstack);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
inventoryplayer.setPickedItemStack(itemstack);
|
||||
this.playerController.sendSlotPacket(this.player.getHeldItem(EnumHand.MAIN_HAND), 36 + inventoryplayer.currentItem);
|
||||
}
|
||||
else if (i != -1)
|
||||
{
|
||||
if (InventoryPlayer.isHotbar(i))
|
||||
{
|
||||
inventoryplayer.currentItem = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.playerController.pickItem(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
ItemStack result;
|
||||
boolean isCreative = player.abilities.isCreativeMode;
|
||||
TileEntity te = null;
|
||||
@@ -463,12 +308,10 @@ public class ForgeHooks
|
||||
{
|
||||
IBlockState state = world.getBlockState(target.getBlockPos());
|
||||
|
||||
if (state.getBlock().isAir(state, world, target.getBlockPos()))
|
||||
{
|
||||
if (state.isAir(world, target.getBlockPos()))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isCreative && GuiScreen.isCtrlKeyDown() && state.getBlock().hasTileEntity(state))
|
||||
if (isCreative && GuiScreen.isCtrlKeyDown() && state.hasTileEntity())
|
||||
te = world.getTileEntity(target.getBlockPos());
|
||||
|
||||
result = state.getBlock().getPickBlock(state, target, world, target.getBlockPos(), player);
|
||||
@@ -754,7 +597,7 @@ public class ForgeHooks
|
||||
boolean preCancelEvent = false;
|
||||
ItemStack itemstack = entityPlayer.getHeldItemMainhand();
|
||||
if (gameType.isCreative() && !itemstack.isEmpty()
|
||||
&& !itemstack.getItem().canDestroyBlockInCreative(world, pos, itemstack, entityPlayer))
|
||||
&& !itemstack.getItem().canPlayerBreakBlockWhileHolding(world.getBlockState(pos), world, pos, entityPlayer))
|
||||
preCancelEvent = true;
|
||||
|
||||
if (gameType.hasLimitedInteractions())
|
||||
|
||||
@@ -37,6 +37,7 @@ import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityWitherSkull;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.MobEffects;
|
||||
@@ -65,6 +66,7 @@ import net.minecraft.world.dimension.EndDimension;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
@@ -216,7 +218,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default public boolean canHarvestBlock(IBlockState state, IBlockReader world, BlockPos pos, EntityPlayer player)
|
||||
{
|
||||
return net.minecraftforge.common.ForgeHooks.canHarvestBlock(state, player, world, pos);
|
||||
return ForgeHooks.canHarvestBlock(state, player, world, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,12 +238,13 @@ public interface IForgeBlock
|
||||
* @param pos Block position in world
|
||||
* @param willHarvest True if Block.harvestBlock will be called after this, if the return in true.
|
||||
* Can be useful to delay the destruction of tile entities till after harvestBlock
|
||||
* @param fluid The current fluid state at current position
|
||||
* @return True if the block is actually destroyed.
|
||||
*/
|
||||
default boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
|
||||
default boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest, IFluidState fluid)
|
||||
{
|
||||
getBlock().onBlockHarvested(world, pos, state, player);
|
||||
return world.setBlockState(pos, net.minecraft.init.Blocks.AIR.getDefaultState(), world.isRemote ? 11 : 3);
|
||||
return world.setBlockState(pos, fluid.getBlockState(), world.isRemote ? 11 : 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -508,6 +511,24 @@ public interface IForgeBlock
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a digging particle effect in the world, this is a wrapper
|
||||
* around EffectRenderer.addBlockHitEffects to allow the block more
|
||||
* control over the particles. Useful when you have entirely different
|
||||
* texture sheets for different sides/locations in the world.
|
||||
*
|
||||
* @param state The current state
|
||||
* @param world The current world
|
||||
* @param target The target the player is looking at {x/y/z/side/sub}
|
||||
* @param manager A reference to the current particle manager.
|
||||
* @return True to prevent vanilla digging particles form spawning.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn particles for when the block is destroyed. Due to the nature
|
||||
* of how this is invoked, the x/y/z locations are not always guaranteed
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry.SpawnPlacementType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -199,11 +200,12 @@ public interface IForgeBlockState
|
||||
* @param pos Block position in world
|
||||
* @param willHarvest True if Block.harvestBlock will be called after this, if the return in true.
|
||||
* Can be useful to delay the destruction of tile entities till after harvestBlock
|
||||
* @param fluid The current fluid and block state for the position in the world.
|
||||
* @return True if the block is actually destroyed.
|
||||
*/
|
||||
default boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
|
||||
default boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest, IFluidState fluid)
|
||||
{
|
||||
return getBlockState().getBlock().removedByPlayer(getBlockState(), world, pos, player, willHarvest);
|
||||
return getBlockState().getBlock().removedByPlayer(getBlockState(), world, pos, player, willHarvest, fluid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,6 +451,23 @@ public interface IForgeBlockState
|
||||
return getBlockState().getBlock().addRunningEffects(getBlockState(), world, pos, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a digging particle effect in the world, this is a wrapper
|
||||
* around EffectRenderer.addBlockHitEffects to allow the block more
|
||||
* control over the particles. Useful when you have entirely different
|
||||
* texture sheets for different sides/locations in the world.
|
||||
*
|
||||
* @param world The current world
|
||||
* @param target The target the player is looking at {x/y/z/side/sub}
|
||||
* @param manager A reference to the current particle manager.
|
||||
* @return True to prevent vanilla digging particles form spawning.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default boolean addHitEffects(World world, RayTraceResult target, ParticleManager manager)
|
||||
{
|
||||
return getBlockState().getBlock().addHitEffects(getBlockState(), world, target, manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn particles for when the block is destroyed. Due to the nature
|
||||
* of how this is invoked, the x/y/z locations are not always guaranteed
|
||||
|
||||
@@ -21,6 +21,7 @@ package net.minecraftforge.common.extensions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.audio.MusicTicker;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.NetherDimension;
|
||||
@@ -44,7 +45,7 @@ public interface IForgeDimension
|
||||
* and VillageCollection are initialized. On client, called when world is
|
||||
* constructed, just before world load event is called. Note that this method is
|
||||
* always called before the world load event.
|
||||
*
|
||||
*
|
||||
* @return initial holder for capabilities on the world
|
||||
*/
|
||||
default net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities()
|
||||
@@ -58,7 +59,7 @@ public interface IForgeDimension
|
||||
* worldA.provider.getMovementFactor() / worldB.provider.getMovementFactor()
|
||||
* Example: Overworld factor is 1, nether factor is 8. Traveling from overworld
|
||||
* to nether multiplies coordinates by 1/8.
|
||||
*
|
||||
*
|
||||
* @return The movement factor
|
||||
*/
|
||||
default double getMovementFactor()
|
||||
@@ -103,7 +104,7 @@ public interface IForgeDimension
|
||||
void setWeatherRenderer(IRenderHandler renderer);
|
||||
|
||||
void resetRainAndThunder();
|
||||
|
||||
|
||||
default boolean canDoLightning(net.minecraft.world.chunk.Chunk chunk)
|
||||
{
|
||||
return true;
|
||||
@@ -113,4 +114,16 @@ public interface IForgeDimension
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on the client to get the music type to play when in this world type.
|
||||
* At the time of calling, the client player and world are guaranteed to be non-null
|
||||
* @return null to use vanilla logic, otherwise a MusicType to play in this world
|
||||
*/
|
||||
@Nullable
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default MusicTicker.MusicType getMusicType()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -532,22 +532,6 @@ public interface IForgeItem
|
||||
stack.getOrCreateTag().setInt("Damage", Math.max(0, damage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checked from
|
||||
* {@link net.minecraft.client.multiplayer.PlayerControllerMP#onPlayerDestroyBlock(BlockPos pos)
|
||||
* PlayerControllerMP.onPlayerDestroyBlock()} when a creative player left-clicks
|
||||
* a block with this item. Also checked from
|
||||
* {@link net.minecraftforge.common.ForgeHooks#onBlockBreakEvent(World, GameType, EntityPlayerMP, BlockPos)
|
||||
* ForgeHooks.onBlockBreakEvent()} to prevent sending an event.
|
||||
*
|
||||
* @return true if the given player can destroy specified block in creative mode
|
||||
* with this item
|
||||
*/
|
||||
default boolean canDestroyBlockInCreative(World world, BlockPos pos, ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
return !(this instanceof ItemSword);
|
||||
}
|
||||
|
||||
/**
|
||||
* ItemStack sensitive version of {@link #canHarvestBlock(IBlockState)}
|
||||
*
|
||||
|
||||
@@ -123,5 +123,30 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
|
||||
getStack().write(ret);
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* Called before a block is broken. Return true to prevent default block
|
||||
* harvesting.
|
||||
*
|
||||
* Note: In SMP, this is called on both client and server sides!
|
||||
*
|
||||
* @param pos Block's position in world
|
||||
* @param player The Player that is wielding the item
|
||||
* @return True to prevent harvesting, false to continue as normal
|
||||
*/
|
||||
default boolean onBlockStartBreak(BlockPos pos, EntityPlayer player)
|
||||
{
|
||||
return getStack().isEmpty() || getStack().getItem().onBlockStartBreak(getStack(), pos, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player is mining a block and the item in his hand changes.
|
||||
* Allows to not reset blockbreaking if only NBT or similar changes.
|
||||
*
|
||||
* @param newStack The new stack
|
||||
* @return True to reset block break progress
|
||||
*/
|
||||
default boolean shouldCauseBlockBreakReset(ItemStack newStack)
|
||||
{
|
||||
return getStack().getItem().shouldCauseBlockBreakReset(getStack(), newStack);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound>
|
||||
{
|
||||
default TileEntity getTileEntity() { return (TileEntity) this; }
|
||||
|
||||
|
||||
@Override
|
||||
default void deserializeNBT(NBTTagCompound nbt)
|
||||
{
|
||||
@@ -40,4 +40,35 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
|
||||
getTileEntity().write(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when you receive a TileEntityData packet for the location this
|
||||
* TileEntity is currently in. On the client, the NetworkManager will always
|
||||
* be the remote server. On the server, it will be whomever is responsible for
|
||||
* sending the packet.
|
||||
*
|
||||
* @param net The NetworkManager the packet originated from
|
||||
* @param pkt The data packet
|
||||
*/
|
||||
default void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SPacketUpdateTileEntity pkt){ }
|
||||
|
||||
/**
|
||||
* Called when the chunk's TE update tag, gotten from {@link #getUpdateTag()}, is received on the client.
|
||||
* <p>
|
||||
* Used to handle this tag in a special way. By default this simply calls {@link #readFromNBT(NBTTagCompound)}.
|
||||
*
|
||||
* @param tag The {@link NBTTagCompound} sent from {@link #getUpdateTag()}
|
||||
*/
|
||||
default void handleUpdateTag(NBTTagCompound tag)
|
||||
{
|
||||
getTileEntity().read(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link NBTTagCompound} that can be used to store custom data for this tile entity.
|
||||
* It will be written, and read from disc, so it persists over world saves.
|
||||
*
|
||||
* @return A compound tag for custom data
|
||||
*/
|
||||
NBTTagCompound getTileData();
|
||||
}
|
||||
Reference in new issue
Block a user