下面列出了net.minecraft.util.EntitySelectors#net.minecraftforge.fml.relauncher.SideOnly 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SideOnly(Side.CLIENT)
public static void entityRender() {
RenderingRegistry.registerEntityRenderingHandler(EntityTofuCow.class, RenderTofuCow::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofuSlime.class, RenderTofuSlime::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofunian.class, RenderTofunian::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofuChinger.class, RenderTofuChinger::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofuSpider.class, RenderTofuSpider::new);
RenderingRegistry.registerEntityRenderingHandler(EntityFukumame.class, RenderFukumame::new);
RenderingRegistry.registerEntityRenderingHandler(EntityZundaArrow.class, RenderZundaArrow::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofuFish.class, RenderTofuFish::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofuTurret.class, RenderTofuTurret::new);
RenderingRegistry.registerEntityRenderingHandler(EntityBeam.class, RenderBeam::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofuMindCore.class, RenderTofuMindCore::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTofuGandlem.class, RenderTofuGandlem::new);
RenderingRegistry.registerEntityRenderingHandler(EntityFallTofu.class, RenderFallTofu::new);
RenderingRegistry.registerEntityRenderingHandler(EntityTippedChingerArrow.class, RenderTippedChingerArrow::new);
}
@Override
@SideOnly(Side.CLIENT)
public Vec3d getFogColor(World world, BlockPos pos, IBlockState state, Entity entity, Vec3d originalColor,
float partialTicks) {
if (!isWithinFluid(world, pos, ActiveRenderInfo.projectViewFromEntity(entity, partialTicks))) {
BlockPos otherPos = pos.down(densityDir);
IBlockState otherState = world.getBlockState(otherPos);
return otherState.getBlock().getFogColor(world, otherPos, otherState, entity, originalColor, partialTicks);
}
if (getFluid() != null) {
return new Vec3d(5.0F, 5.0F, 5.0F);
}
return super.getFogColor(world, pos, state, entity, originalColor, partialTicks);
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onItemTooltip(ItemTooltipEvent event)
{
ItemStack stack = event.getItemStack();
if (!stack.isEmpty() && CommunityGlobals.MOD_ID.equals(stack.getItem().getRegistryName().getNamespace()))
{
SubModContainer subMod = SubModLoader.getSubModOrigin(stack.getItem());
if (subMod != null)
{
event.getToolTip().add(TextFormatting.DARK_GRAY + "(" + subMod.getName() + " - " + subMod.getAttribution() + ")");
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
super.randomDisplayTick(state, world, pos, rand);
if (world.getBlockState(pos.up()).getMaterial() != Material.WATER && rand.nextInt(3) == 0)
{
if (this.getHeatStrength(world, pos) > 0)
{
float steamX = pos.getX() + 0.5F;
float steamY = pos.getY() + 0.9F;
float steamZ = pos.getZ() + 0.5F;
float steamRandX = rand.nextFloat() * 0.6F - 0.3F;
float steamRandZ = rand.nextFloat() * 0.6F - 0.3F;
double gRand1 = rand.nextGaussian() * 0.01D;
double gRand2 = rand.nextGaussian() * 0.01D;
double gRand3 = rand.nextGaussian() * 0.01D;
world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (steamX + steamRandX), steamY, (steamZ + steamRandZ), gRand1, gRand2, gRand3);
}
}
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("deprecation") //how to mod 101
public void onInit(FMLInitializationEvent event) {
IReloadableResourceManager mgr = ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager());
mgr.registerReloadListener((x) -> {
Minecraft mc = Minecraft.getMinecraft();
mc.fontRenderer = new SexyFontRenderer(
mc.gameSettings,
new ResourceLocation("textures/font/ascii.png"),
mc.renderEngine,
mc.isUnicode()
);
});
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
Blocks.LEAVES.randomDisplayTick(stateIn, worldIn, pos, rand);
if (rand.nextInt(40) == 0) {
int j = rand.nextInt(2) * 2 - 1;
int k = rand.nextInt(2) * 2 - 1;
double d0 = pos.getX() + 0.5D + 0.25D * j;
double d1 = pos.getY() - 0.15D;
double d2 = pos.getZ() + 0.5D + 0.25D * k;
double d3 = rand.nextFloat() * j * 0.1D;
double d4 = ((rand.nextFloat()) * 0.055D) + 0.015D;
double d5 = rand.nextFloat() * k * 0.1D;
SakuraMain.proxy.spawnParticle(SakuraParticleType.MAPLEYELLOW, d0, d1, d2, d3, -d4, d5);
}
}
/**
* Load a new instance of HarvesterAnimationStateMachine at specified location,
* with specified custom parameters.
*/
@SideOnly(Side.CLIENT)
public static HarvesterAnimationStateMachine load(IResourceManager manager, ResourceLocation location,
ImmutableMap<String, ITimeValue> customParameters) {
try (IResource resource = manager.getResource(location)) {
ClipResolver clipResolver = new ClipResolver();
ParameterResolver parameterResolver = new ParameterResolver(customParameters);
Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver);
TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver);
HarvesterAnimationStateMachine asm = asmGson.fromJson(
new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8),
HarvesterAnimationStateMachine.class);
clipResolver.asm = asm;
parameterResolver.asm = asm;
asm.initialize();
return asm;
} catch (IOException | JsonParseException e) {
FMLLog.log.error("Exception loading Animation State Machine {}, skipping", location, e);
return missing;
} finally {
Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null);
TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null);
}
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
Blocks.LEAVES.randomDisplayTick(stateIn, worldIn, pos, rand);
if (rand.nextInt(40) == 0) {
int j = rand.nextInt(2) * 2 - 1;
int k = rand.nextInt(2) * 2 - 1;
double d0 = pos.getX() + 0.5D + 0.25D * j;
double d1 = pos.getY() - 0.15D;
double d2 = pos.getZ() + 0.5D + 0.25D * k;
double d3 = rand.nextFloat() * j * 0.1D;
double d4 = ((rand.nextFloat()) * 0.055D) + 0.015D;
double d5 = rand.nextFloat() * k * 0.1D;
SakuraMain.proxy.spawnParticle(SakuraParticleType.MAPLERED, d0, d1, d2, d3, -d4, d5);
}
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
if (!Minecraft.getMinecraft().gameSettings.fancyGraphics) {
if (!(blockAccess.getBlockState(pos.offset(side)).getBlock() instanceof BlockLeaves)) {
return true;
}
return false;
}
return true;
}
@SideOnly(Side.CLIENT)
public void setTurbineStateClient(TurbineSpeedEnum speed) {
String state = this.getAnimator().currentState();
String newState = TidalHelper.getTurbineStateFromSpeedEnum(speed);
if (!state.equalsIgnoreCase(newState)) {
this.getAnimator().transition(newState);
}
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced)
{
int range = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.lightBlockRange;
int energy = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.lightEnergyBaseUsage;
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.LIGHT_DESC));
tooltip.add(Lang.getLightRange(range));
tooltip.add(Lang.getRequired(energy, ResourceTypeEnum.ENERGY));
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced)
{
int loss = EmergingTechnologyConfig.SYNTHETICS_MODULE.COOKER.cookerBaseHeatLoss;
int gain = EmergingTechnologyConfig.SYNTHETICS_MODULE.COOKER.cookerBaseHeatGain;
int heat = EmergingTechnologyConfig.SYNTHETICS_MODULE.COOKER.cookerRequiredCookingHeat;
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.COOKER_DESC));
tooltip.add(Lang.getHeatGainLoss(gain, loss));
tooltip.add(Lang.getRequired(heat, ResourceTypeEnum.HEAT));
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
public ItemKatana(Item.ToolMaterial material, String name) {
this.material = material;
this.maxStackSize = 1;
this.setMaxDamage(material.getMaxUses());
this.setUnlocalizedName(SakuraMain.MODID + "." + name);
this.attackDamage = 3.0F + material.getAttackDamage();
this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F;
}
});
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced)
{
int lightBaseEnergy = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.lightEnergyBaseUsage;
int growth = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.growthGreenBulbModifier;
int energy = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.energyGreenBulbModifier * lightBaseEnergy;
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.BULB_DESC));
tooltip.add(Lang.getRequired(energy, ResourceTypeEnum.ENERGY));
tooltip.add(Lang.getGenerated(growth, ResourceTypeEnum.GROWTH));
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
@SideOnly(Side.CLIENT)
public static void render() {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCampfire.class, new RenderTileEntityCampfire());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStoneMortar.class, new RenderTileEntityStoneMortar());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCampfirePot.class, new RenderTileEntityCampfirePot());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMapleCauldron.class, new RenderTileEntityMapleCauldron());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShoji.class, new ShojiRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityOben.class, new RenderTileEntityOben());
getItem(BlockLoader.STONEMORTAR).setTileEntityItemStackRenderer(new TileEntityRenderHelper());
}
public ItemTofuShield(int damage) {
super();
this.setMaxStackSize(1);
this.setMaxDamage(damage);
this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F;
}
});
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, ItemArmor.DISPENSER_BEHAVIOR);
}
public ItemTofuCore() {
super();
this.setMaxStackSize(1);
this.setMaxDamage(300);
this.setUnlocalizedName(TofuMain.MODID + "." + "tofucore");
this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return isUsable(stack) ? 0.0F : 1.0F;
}
});
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
//tooltip.add(I18n.translateToLocal("tooltip.tofucraft.tofuforce_core2"));
if (!isUsable(stack)) {
tooltip.add(TextFormatting.ITALIC + I18n.format("tooltip.tofucraft.tofuforce_core.broken"));
}
super.addInformation(stack, worldIn, tooltip, flagIn);
}
public ItemTofuForceCore() {
super();
this.setMaxStackSize(1);
this.setMaxDamage(360);
this.setUnlocalizedName(TofuMain.MODID + "." + "tofuforce_core");
this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return isUsable(stack) ? 0.0F : 1.0F;
}
});
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced) {
int energy = EmergingTechnologyConfig.ELECTRICS_MODULE.SOLARGLASS.solarEnergyGenerated;
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.SOLARGLASS_DESC));
tooltip.add(Lang.getGenerated(energy, ResourceTypeEnum.ENERGY));
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced) {
int energy = EmergingTechnologyConfig.HYDROPONICS_MODULE.DIFFUSER.diffuserEnergyBaseUsage;
int gas = EmergingTechnologyConfig.HYDROPONICS_MODULE.DIFFUSER.diffuserGasBaseUsage;
int range = EmergingTechnologyConfig.HYDROPONICS_MODULE.DIFFUSER.diffuserBaseRange;
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.DIFFUSER_DESC));
tooltip.add(Lang.getGasRange(range));
tooltip.add(Lang.getRequired(gas, ResourceTypeEnum.GAS));
tooltip.add(Lang.getRequired(energy, ResourceTypeEnum.ENERGY));
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
@SideOnly(Side.CLIENT)
public void draw(GuiRoutiduct gui) {
if (sprite != null) {
GlStateManager.color(1F, 1F, 1F);
Routiduct.proxy.getGuiAssembler().setTextureSheet(sprite.textureLocation);
gui.drawTexturedModalRect(x + gui.getOffsetFactorX(), y + gui.getOffsetFactorY(), sprite.x, sprite.y, sprite.width, sprite.height);
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onClientTick(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.START) {
Minecraft client = Minecraft.getMinecraft();
if (client.world != null && !client.isGamePaused()) {
RANDOM.setSeed((client.world.getTotalWorldTime() * M) ^ client.world.getSeed());
if (RANDOM.nextInt(CHANCE) == 0) {
ISound sound = PositionedSoundRecord.getMasterRecord(YOU_COULD_MAKE_A_RELIGION_OUT_OF_THIS, 1.0F);
client.getSoundHandler().playSound(sound);
}
}
}
}
/**
* Returns remaining burn time in integer between 0 and par1
*/
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1) {
if (this.currentItemBurnTime == 0) {
this.currentItemBurnTime = 200;
}
return this.furnaceBurnTime * par1 / this.currentItemBurnTime;
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced) {
int energy = EmergingTechnologyConfig.POLYMERS_MODULE.SHREDDER.shredderEnergyBaseUsage;
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.SHREDDER_DESC));
tooltip.add(Lang.getRequired(energy, ResourceTypeEnum.ENERGY));
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced) {
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.NOZZLE_DESC));
tooltip.add(getSpecialDescription());
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
@SideOnly(Side.CLIENT)
public static void registerModels(ModelRegistryEvent event) {
for (Block block : ModBlocks.getBlocks()) {
registerModel(Item.getItemFromBlock(block));
}
for (Item item : ModItems.getItems()) {
registerModel(item);
}
registerModTissueModels();
// Hydroponic TESR
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.hydroponic), 0,
new ModelResourceLocation(ModBlocks.hydroponic.getRegistryName(), "inventory"));
ClientRegistry.bindTileEntitySpecialRenderer(HydroponicTileEntity.class, new HydroponicTESR());
ClientRegistry.bindTileEntitySpecialRenderer(TidalGeneratorTileEntity.class,
new AnimationTESR<TidalGeneratorTileEntity>());
ClientRegistry.bindTileEntitySpecialRenderer(WindTileEntity.class, new AnimationTESR<WindTileEntity>());
ClientRegistry.bindTileEntitySpecialRenderer(ScrubberTileEntity.class, new AnimationTESR<ScrubberTileEntity>());
ClientRegistry.bindTileEntitySpecialRenderer(HarvesterTileEntity.class, new AnimationTESR<HarvesterTileEntity>());
RenderHandler.registerMeshesAndStatesForBlock(ModBlocks.carbondioxideblock);
RenderHandler.registerMeshesAndStatesForBlock(ModBlocks.nutrientblock);
}
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World player, List<String> tooltip, ITooltipFlag advanced)
{
int lightBaseEnergy = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.lightEnergyBaseUsage;
int growth = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.growthPurpleBulbModifier;
int energy = EmergingTechnologyConfig.HYDROPONICS_MODULE.GROWLIGHT.energyPurpleBulbModifier * lightBaseEnergy;
if (KeyBindings.showExtendedTooltips()) {
tooltip.add(Lang.get(Lang.BULB_DESC));
tooltip.add(Lang.getRequired(energy, ResourceTypeEnum.ENERGY));
tooltip.add(Lang.getGenerated(growth, ResourceTypeEnum.GROWTH));
} else {
tooltip.add(Lang.get(Lang.INTERACT_SHIFT));
}
}
public ItemKotachi(Item.ToolMaterial material, String name) {
this.material = material;
this.maxStackSize = 1;
this.setMaxDamage((int) (material.getMaxUses()*0.75f));
this.setUnlocalizedName(SakuraMain.MODID + "." + name);
this.attackDamage = material.getAttackDamage();
this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F;
}
});
}
@SideOnly(Side.CLIENT)
@Override
public void registerModels(ModelRegistryEvent event) {
ClientUtil.simpleItemModel(JPEG_GOGGLES);
}