2019-01-01 01:10:18 +00:00
|
|
|
/*
|
|
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
|
|
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
|
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
|
|
*/
|
|
|
|
|
2017-05-01 13:32:39 +00:00
|
|
|
package dan200.computercraft.client.render;
|
|
|
|
|
2017-05-01 13:51:26 +00:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
import net.minecraft.client.renderer.model.BakedQuad;
|
|
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
|
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|
|
|
import net.minecraft.client.renderer.model.ItemOverrideList;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
import javax.annotation.Nonnull;
|
2017-05-01 13:32:39 +00:00
|
|
|
import javax.vecmath.Matrix4f;
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
import java.util.*;
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2017-05-01 13:51:26 +00:00
|
|
|
public class TurtleMultiModel implements IBakedModel
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-11-21 00:34:35 +00:00
|
|
|
private final IBakedModel m_baseModel;
|
|
|
|
private final IBakedModel m_overlayModel;
|
|
|
|
private final Matrix4f m_generalTransform;
|
|
|
|
private final IBakedModel m_leftUpgradeModel;
|
|
|
|
private final Matrix4f m_leftUpgradeTransform;
|
|
|
|
private final IBakedModel m_rightUpgradeModel;
|
|
|
|
private final Matrix4f m_rightUpgradeTransform;
|
2019-03-29 21:21:39 +00:00
|
|
|
private List<BakedQuad> m_generalQuads = null;
|
|
|
|
private Map<EnumFacing, List<BakedQuad>> m_faceQuads = new EnumMap<>( EnumFacing.class );
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2017-11-21 00:34:35 +00:00
|
|
|
public TurtleMultiModel( IBakedModel baseModel, IBakedModel overlayModel, Matrix4f generalTransform, IBakedModel leftUpgradeModel, Matrix4f leftUpgradeTransform, IBakedModel rightUpgradeModel, Matrix4f rightUpgradeTransform )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
// Get the models
|
2017-05-01 13:51:26 +00:00
|
|
|
m_baseModel = baseModel;
|
|
|
|
m_overlayModel = overlayModel;
|
|
|
|
m_leftUpgradeModel = leftUpgradeModel;
|
|
|
|
m_leftUpgradeTransform = leftUpgradeTransform;
|
|
|
|
m_rightUpgradeModel = rightUpgradeModel;
|
|
|
|
m_rightUpgradeTransform = rightUpgradeTransform;
|
2017-11-21 00:34:35 +00:00
|
|
|
m_generalTransform = generalTransform;
|
2017-05-01 13:51:26 +00:00
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nonnull
|
2017-05-01 13:51:26 +00:00
|
|
|
@Override
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, @Nonnull Random rand )
|
2017-05-01 13:51:26 +00:00
|
|
|
{
|
|
|
|
if( side != null )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2017-11-21 00:18:03 +00:00
|
|
|
if( !m_faceQuads.containsKey( side ) ) m_faceQuads.put( side, buildQuads( state, side, rand ) );
|
2017-05-29 15:35:41 +00:00
|
|
|
return m_faceQuads.get( side );
|
2017-05-01 13:51:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-21 00:18:03 +00:00
|
|
|
if( m_generalQuads == null ) m_generalQuads = buildQuads( state, side, rand );
|
2017-05-01 13:51:26 +00:00
|
|
|
return m_generalQuads;
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
private List<BakedQuad> buildQuads( IBlockState state, EnumFacing side, Random rand )
|
2017-11-21 00:18:03 +00:00
|
|
|
{
|
|
|
|
ArrayList<BakedQuad> quads = new ArrayList<>();
|
2017-11-21 00:34:35 +00:00
|
|
|
ModelTransformer.transformQuadsTo( quads, m_baseModel.getQuads( state, side, rand ), m_generalTransform );
|
2017-11-21 00:18:03 +00:00
|
|
|
if( m_overlayModel != null )
|
|
|
|
{
|
2017-11-21 00:34:35 +00:00
|
|
|
ModelTransformer.transformQuadsTo( quads, m_overlayModel.getQuads( state, side, rand ), m_generalTransform );
|
|
|
|
}
|
|
|
|
if( m_overlayModel != null )
|
|
|
|
{
|
|
|
|
ModelTransformer.transformQuadsTo( quads, m_overlayModel.getQuads( state, side, rand ), m_generalTransform );
|
2017-11-21 00:18:03 +00:00
|
|
|
}
|
|
|
|
if( m_leftUpgradeModel != null )
|
|
|
|
{
|
2017-11-21 00:34:35 +00:00
|
|
|
Matrix4f upgradeTransform = m_generalTransform;
|
|
|
|
if( m_leftUpgradeTransform != null )
|
|
|
|
{
|
|
|
|
upgradeTransform = new Matrix4f( m_generalTransform );
|
|
|
|
upgradeTransform.mul( m_leftUpgradeTransform );
|
|
|
|
}
|
|
|
|
ModelTransformer.transformQuadsTo( quads, m_leftUpgradeModel.getQuads( state, side, rand ), upgradeTransform );
|
2017-11-21 00:18:03 +00:00
|
|
|
}
|
|
|
|
if( m_rightUpgradeModel != null )
|
|
|
|
{
|
2017-11-21 00:34:35 +00:00
|
|
|
Matrix4f upgradeTransform = m_generalTransform;
|
|
|
|
if( m_rightUpgradeTransform != null )
|
|
|
|
{
|
|
|
|
upgradeTransform = new Matrix4f( m_generalTransform );
|
|
|
|
upgradeTransform.mul( m_rightUpgradeTransform );
|
|
|
|
}
|
|
|
|
ModelTransformer.transformQuadsTo( quads, m_rightUpgradeModel.getQuads( state, side, rand ), upgradeTransform );
|
2017-11-21 00:18:03 +00:00
|
|
|
}
|
|
|
|
quads.trimToSize();
|
|
|
|
return quads;
|
|
|
|
}
|
|
|
|
|
2017-05-01 13:32:39 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAmbientOcclusion()
|
|
|
|
{
|
|
|
|
return m_baseModel.isAmbientOcclusion();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isGui3d()
|
|
|
|
{
|
|
|
|
return m_baseModel.isGui3d();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBuiltInRenderer()
|
|
|
|
{
|
|
|
|
return m_baseModel.isBuiltInRenderer();
|
|
|
|
}
|
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nonnull
|
2017-05-01 13:32:39 +00:00
|
|
|
@Override
|
|
|
|
public TextureAtlasSprite getParticleTexture()
|
|
|
|
{
|
|
|
|
return m_baseModel.getParticleTexture();
|
|
|
|
}
|
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nonnull
|
2017-05-01 13:32:39 +00:00
|
|
|
@Override
|
2017-05-07 00:42:32 +00:00
|
|
|
@Deprecated
|
2017-05-01 13:32:39 +00:00
|
|
|
public ItemCameraTransforms getItemCameraTransforms()
|
|
|
|
{
|
|
|
|
return m_baseModel.getItemCameraTransforms();
|
|
|
|
}
|
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nonnull
|
2017-05-01 13:32:39 +00:00
|
|
|
@Override
|
2017-05-01 13:51:26 +00:00
|
|
|
public ItemOverrideList getOverrides()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
return ItemOverrideList.EMPTY;
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|