nosingleplayer 1.1.1: fond custom via blit + log debug widgets
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
|
||||
package net.paladrill.paladrillmod.item;
|
||||
|
||||
import net.paladrill.paladrillmod.procedure.ProcedureEndiumDynamiteHit;
|
||||
import net.paladrill.paladrillmod.creativetab.TabPalaDrillMod;
|
||||
import net.paladrill.paladrillmod.ElementsPaladrillmodMod;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.init.Enchantments;
|
||||
import net.minecraft.entity.projectile.EntityTippedArrow;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderSnowball;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@ElementsPaladrillmodMod.ModElement.Tag
|
||||
public class ItemEndiumDynamite extends ElementsPaladrillmodMod.ModElement {
|
||||
@GameRegistry.ObjectHolder("paladrillmod:endiumdynamite")
|
||||
public static final Item block = null;
|
||||
public static final int ENTITYID = 3;
|
||||
public ItemEndiumDynamite(ElementsPaladrillmodMod instance) {
|
||||
super(instance, 99);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initElements() {
|
||||
elements.items.add(() -> new RangedItem());
|
||||
elements.entities.add(() -> EntityEntryBuilder.create().entity(EntityArrowCustom.class)
|
||||
.id(new ResourceLocation("paladrillmod", "entitybulletendiumdynamite"), ENTITYID).name("entitybulletendiumdynamite")
|
||||
.tracker(64, 1, true).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation("paladrillmod:endiumdynamite", "inventory"));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityArrowCustom.class, renderManager -> {
|
||||
return new RenderSnowball(renderManager, new ItemStack(ItemEndiumDynamite.block, (int) (1)).getItem(),
|
||||
Minecraft.getMinecraft().getRenderItem());
|
||||
});
|
||||
}
|
||||
public static class RangedItem extends Item {
|
||||
public RangedItem() {
|
||||
super();
|
||||
setMaxDamage(0);
|
||||
setFull3D();
|
||||
setUnlocalizedName("endiumdynamite");
|
||||
setRegistryName("endiumdynamite");
|
||||
maxStackSize = 64;
|
||||
setCreativeTab(TabPalaDrillMod.tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityLivingBase entityLivingBase, int timeLeft) {
|
||||
if (!world.isRemote && entityLivingBase instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP entity = (EntityPlayerMP) entityLivingBase;
|
||||
int slotID = -1;
|
||||
for (int i = 0; i < entity.inventory.mainInventory.size(); i++) {
|
||||
ItemStack stack = entity.inventory.mainInventory.get(i);
|
||||
if (stack != null && stack.getItem() == new ItemStack(ItemEndiumDynamite.block, (int) (1)).getItem()
|
||||
&& stack.getMetadata() == new ItemStack(ItemEndiumDynamite.block, (int) (1)).getMetadata()) {
|
||||
slotID = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (entity.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, itemstack) > 0
|
||||
|| slotID != -1) {
|
||||
float power = 1f;
|
||||
EntityArrowCustom entityarrow = new EntityArrowCustom(world, entity);
|
||||
entityarrow.shoot(entity.getLookVec().x, entity.getLookVec().y, entity.getLookVec().z, power * 2, 0);
|
||||
entityarrow.setSilent(true);
|
||||
entityarrow.setIsCritical(true);
|
||||
entityarrow.setDamage(1.2000000000000002);
|
||||
entityarrow.setKnockbackStrength(3);
|
||||
entityarrow.setFire(100);
|
||||
itemstack.damageItem(1, entity);
|
||||
int x = (int) entity.posX;
|
||||
int y = (int) entity.posY;
|
||||
int z = (int) entity.posZ;
|
||||
world.playSound((EntityPlayer) null, (double) x, (double) y, (double) z,
|
||||
(net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation((""))),
|
||||
SoundCategory.NEUTRAL, 1, 1f / (itemRand.nextFloat() * 0.5f + 1f) + (power / 2));
|
||||
if (entity.capabilities.isCreativeMode) {
|
||||
entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
} else {
|
||||
if (new ItemStack(ItemEndiumDynamite.block, (int) (1)).isItemStackDamageable()) {
|
||||
ItemStack stack = entity.inventory.getStackInSlot(slotID);
|
||||
if (stack.attemptDamageItem(1, itemRand, entity)) {
|
||||
stack.shrink(1);
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
} else {
|
||||
entity.inventory.clearMatchingItems(new ItemStack(ItemEndiumDynamite.block, (int) (1)).getItem(), -1, 1, null);
|
||||
}
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.spawnEntity(entityarrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer entity, EnumHand hand) {
|
||||
entity.setActiveHand(hand);
|
||||
return new ActionResult(EnumActionResult.SUCCESS, entity.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack itemstack) {
|
||||
return EnumAction.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack itemstack) {
|
||||
return 72000;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityArrowCustom extends EntityTippedArrow {
|
||||
public EntityArrowCustom(World a) {
|
||||
super(a);
|
||||
}
|
||||
|
||||
public EntityArrowCustom(World worldIn, double x, double y, double z) {
|
||||
super(worldIn, x, y, z);
|
||||
}
|
||||
|
||||
public EntityArrowCustom(World worldIn, EntityLivingBase shooter) {
|
||||
super(worldIn, shooter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void arrowHit(EntityLivingBase entity) {
|
||||
super.arrowHit(entity);
|
||||
entity.setArrowCountInEntity(entity.getArrowCountInEntity() - 1);
|
||||
int x = (int) this.posX;
|
||||
int y = (int) this.posY;
|
||||
int z = (int) this.posZ;
|
||||
World world = this.world;
|
||||
{
|
||||
Map<String, Object> $_dependencies = new HashMap<>();
|
||||
$_dependencies.put("x", x);
|
||||
$_dependencies.put("y", y);
|
||||
$_dependencies.put("z", z);
|
||||
$_dependencies.put("world", world);
|
||||
ProcedureEndiumDynamiteHit.executeProcedure($_dependencies);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
int x = (int) this.posX;
|
||||
int y = (int) this.posY;
|
||||
int z = (int) this.posZ;
|
||||
World world = this.world;
|
||||
Entity entity = (Entity) shootingEntity;
|
||||
if (this.inGround) {
|
||||
{
|
||||
Map<String, Object> $_dependencies = new HashMap<>();
|
||||
$_dependencies.put("x", x);
|
||||
$_dependencies.put("y", y);
|
||||
$_dependencies.put("z", z);
|
||||
$_dependencies.put("world", world);
|
||||
ProcedureEndiumDynamiteHit.executeProcedure($_dependencies);
|
||||
}
|
||||
this.world.removeEntity(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user